From 512d2ac433f1dbc21e4efbd60da399e92771bd3c Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 26 Apr 2017 10:59:43 +0300 Subject: [PATCH] Bluetooth: L2CAP: Fix unnecessary NULL check The segment allocation function can't fail (it eventually waits with K_FOREVER for a buffer to become available), so there's no point in checking its return value for NULL. Also, the connection state check is because of this particular waiting and not the semaphore waiting (which is done with K_NO_WAIT). Change-Id: I9698760541de810869cffc1c60cf97c5f8f7df8d Signed-off-by: Johan Hedberg --- subsys/bluetooth/host/l2cap.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 2d7a33be10b..06c9121ffd0 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -1080,11 +1080,8 @@ static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch, struct net_buf *buf, } buf = l2cap_chan_create_seg(ch, buf, sdu_hdr_len); - if (!buf) { - return -ENOMEM; - } - /* Channel may have been disconnected while waiting for credits */ + /* Channel may have been disconnected while waiting for a buffer */ if (!ch->chan.conn) { net_buf_unref(buf); return -ECONNRESET;