mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-09 02:42:01 -05:00
Bluetooth: Fix possible NULL pointer dereference in cmd_complete
It is now possible to create command complete event without specific reply data by passing NULL as reply with len 0. Check pointer before calling memcpy to avoid undefined behaviour. Signed-off-by: Szymon Janc <szymon.janc@tieto.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
This commit is contained in:
committed by
Gustavo F. Padovan
parent
30e7627219
commit
8020c16a6c
@@ -92,7 +92,9 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp,
|
||||
|
||||
ev = (void *) skb_put(skb, sizeof(*ev) + rp_len);
|
||||
put_unaligned_le16(cmd, &ev->opcode);
|
||||
memcpy(ev->data, rp, rp_len);
|
||||
|
||||
if (rp)
|
||||
memcpy(ev->data, rp, rp_len);
|
||||
|
||||
if (sock_queue_rcv_skb(sk, skb) < 0)
|
||||
kfree_skb(skb);
|
||||
|
||||
Reference in New Issue
Block a user