Skip to content

Commit 72d061e

Browse files
Dan CarpenterVudentz
authored andcommitted
Bluetooth: Fix error code in chan_alloc_skb_cb()
The chan_alloc_skb_cb() function is supposed to return error pointers on error. Returning NULL will lead to a NULL dereference. Fixes: 6b8d4a6 ("Bluetooth: 6LoWPAN: Use connected oriented channel instead of fixed one") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 2409fa6 commit 72d061e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/bluetooth/6lowpan.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,16 @@ static struct sk_buff *chan_alloc_skb_cb(struct l2cap_chan *chan,
825825
unsigned long hdr_len,
826826
unsigned long len, int nb)
827827
{
828+
struct sk_buff *skb;
829+
828830
/* Note that we must allocate using GFP_ATOMIC here as
829831
* this function is called originally from netdev hard xmit
830832
* function in atomic context.
831833
*/
832-
return bt_skb_alloc(hdr_len + len, GFP_ATOMIC);
834+
skb = bt_skb_alloc(hdr_len + len, GFP_ATOMIC);
835+
if (!skb)
836+
return ERR_PTR(-ENOMEM);
837+
return skb;
833838
}
834839

835840
static void chan_suspend_cb(struct l2cap_chan *chan)

0 commit comments

Comments
 (0)