Skip to content

Commit ef9c7a4

Browse files
Vudentzjhedberg
authored andcommitted
Bluetooth: samples: IPSP: Fix not checking return of net_pkt_read
net_pkt_read may fail in which case the error shall be reported back instead of always assuming the whole packet was read. Fixes #14817 Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent cb44b7e commit ef9c7a4

File tree

1 file changed

+8
-3
lines changed
  • samples/bluetooth/ipsp/src

1 file changed

+8
-3
lines changed

samples/bluetooth/ipsp/src/main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,19 @@ static int build_reply(const char *name,
163163
u8_t *buf)
164164
{
165165
int reply_len = net_pkt_remaining_data(pkt);
166+
int ret;
166167

167168
LOG_DBG("%s received %d bytes", name, reply_len);
168169

169-
net_pkt_read(pkt, buf, reply_len);
170+
ret = net_pkt_read(pkt, buf, reply_len);
171+
if (ret < 0) {
172+
LOG_ERR("cannot read packet: %d", ret);
173+
return ret;
174+
}
170175

171-
LOG_DBG("Received %d bytes, sending %d bytes", reply_len, reply_len);
176+
LOG_DBG("sending %d bytes", ret);
172177

173-
return reply_len;
178+
return ret;
174179
}
175180

176181
static inline void pkt_sent(struct net_context *context,

0 commit comments

Comments
 (0)