Bluetooth: fix potential NULL ptr deref in dtl1_cs.c::dtl1_hci_send_frame()
PATCH 1/1 Bluetooth: fix potential NULL ptr deref in dtl1_cs.c::dtl1_hci_send_frame()
There's a problem in drivers/bluetooth/dtl1_cs.c::dtl1_hci_send_frame()
If bt_skb_alloc() returns NULL, then skb_reserve(s, NSHL); will cause a NULL pointer deref - ouch.
If we can't allocate the resources we require we need to tell the caller by returning -ENOMEM.
Found by the coverity checker as bug #409
Patch is compile tested, but that's all, due to lack of hardware.
---
drivers/bluetooth/dtl1_cs.c | 3 +++ 1 files changed, 3 insertions(+)
drivers/bluetooth/dtl1_cs.c +3 -0
@@ -423,6 +423,9 @@ static int dtl1_hci_send_frame(struct sk nsh.len = skb->len; s =bt_skb_alloc (NSHL + skb->len +1 ,GFP_ATOMIC ); +if (!s) +return -ENOMEM ; +skb_reserve (s,NSHL );memcpy (skb_put (s, skb->len), skb->data, skb->len);if (skb->len &0x0001 )
Marcel Holtmann
maintainerHi Jesper,
Quoted 7 lines
There's a problem in drivers/bluetooth/dtl1_cs.c::dtl1_hci_send_frame()
If
bt_skb_alloc()returns NULL, thenskb_reserve(s, NSHL); will cause a NULL pointer deref - ouch.
If we can't allocate the resources we require we need to tell the caller by returning-ENOMEM.
Quoted 6 lines
Found by the coverity checker as bug #409
Patch is compile tested, but that's all, due to lack of hardware.
Signed-off-by Jesper Juhl <[email protected]>
Regards
Marcel