From: Brian Gix <brian.gix@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: brian.gix@intel.com, inga.stotland@intel.com, prathyusha.n@samsung.com
Subject: [PATCH BlueZ v2 2/3] mesh: Rearrange PB-ACK for possible session close
Date: Tue, 3 Dec 2019 13:04:09 -0800 [thread overview]
Message-ID: <20191203210410.25548-3-brian.gix@intel.com> (raw)
In-Reply-To: <20191203210410.25548-1-brian.gix@intel.com>
In certain circumstances, reception of PB-ADV messages may trigger
session close. This rearrange ACKs new verified messages before
performing call-back to avoid situations where the session no longer
exists after the message has been handled.
This caused static analysis errors during provisioning, which are now
addressed.
---
mesh/net.c | 1 -
mesh/pb-adv.c | 8 ++++----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/mesh/net.c b/mesh/net.c
index 61dd8be32..a60327272 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -2381,7 +2381,6 @@ static enum _relay_advice packet_received(void *user_data,
l_info("RX: App 0x%04x -> 0x%04x : TTL 0x%02x : SEQ 0x%06x",
net_src, net_dst, net_ttl, net_seq);
- l_debug("seq:%x seq0:%x", net_seq, net_seqZero);
if (net_ctl) {
l_debug("CTL - %4.4x RX", net_seqZero);
if (net_opcode == NET_OP_SEG_ACKNOWLEDGE) {
diff --git a/mesh/pb-adv.c b/mesh/pb-adv.c
index 586cd7f15..27cbc469e 100644
--- a/mesh/pb-adv.c
+++ b/mesh/pb-adv.c
@@ -254,7 +254,7 @@ static void pb_adv_packet(void *user_data, const uint8_t *pkt, uint16_t len)
uint8_t type;
bool first;
- if (!session || pb_session != session)
+ if (!pb_session || pb_session != session)
return;
link_id = l_get_be32(pkt + 1);
@@ -426,14 +426,14 @@ static void pb_adv_packet(void *user_data, const uint8_t *pkt, uint16_t len)
return;
}
+ send_ack(session, session->peer_trans_num);
+
if (session->last_peer_trans_num != session->peer_trans_num) {
session->got_segs = 0;
+ session->last_peer_trans_num = session->peer_trans_num;
session->rx_cb(session->user_data, session->sar,
session->exp_len);
}
-
- session->last_peer_trans_num = session->peer_trans_num;
- send_ack(session, session->last_peer_trans_num);
}
}
--
2.21.0
next prev parent reply other threads:[~2019-12-03 21:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-03 21:04 [PATCH BlueZ v2 0/3] mesh: Fix various valgrind identified problems Brian Gix
2019-12-03 21:04 ` [PATCH BlueZ v2 1/3] mesh: Fix to send close indication on timeout Brian Gix
2019-12-03 21:04 ` Brian Gix [this message]
2019-12-03 21:04 ` [PATCH BlueZ v2 3/3] mesh: Fix memory leak in Join() API call Brian Gix
2019-12-04 18:01 ` [PATCH BlueZ v2 0/3] mesh: Fix various valgrind identified problems Gix, Brian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191203210410.25548-3-brian.gix@intel.com \
--to=brian.gix@intel.com \
--cc=inga.stotland@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=prathyusha.n@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).