Skip to content

Commit

Permalink
[PATCH] Bluetooth: fix potential NULL ptr deref in dtl1_cs.c::dtl1_hc…
Browse files Browse the repository at this point in the history
…i_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

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Jesper Juhl authored and Linus Torvalds committed Jun 26, 2006
1 parent 81615b6 commit 57136ca
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/bluetooth/dtl1_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ static int dtl1_hci_send_frame(struct sk_buff *skb)
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)
Expand Down

0 comments on commit 57136ca

Please sign in to comment.