Skip to contentSkip to conversation

NULL check value returned by alloc_skb

PATCH In review Dhiraj Shah 2 participants 2 messages Jun 9, 2021 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NULL check value returned by alloc_skb

Return error ENOMEM if alloc_skb() failed.

---
 drivers/bluetooth/virtio_bt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bluetooth/virtio_bt.c +2 -0
index c804db7e90f8..5f82574236c0 100644
@@ -34,6 +34,8 @@ static int virtbt_add_inbuf(struct virtio_bluetooth *vbt)
 	int err;
 
 	skb = alloc_skb(1000, GFP_KERNEL);
+	if (!skb)
+		return -ENOMEM;
 	sg_init_one(sg, skb->data, 1000);
 
 	err = virtqueue_add_inbuf(vq, sg, 1, skb, GFP_KERNEL);
Signature · 1 line
2.30.1 (Apple Git-130)
maintainer
#1 lore raw

Hi Dhiraj,

Quoted 12 lines

Return error ENOMEM if alloc_skb() failed.

---
drivers/bluetooth/virtio_bt.c | 2 ++

1 file changed, 2 insertions(+)
drivers/bluetooth/virtio_bt.c +0 -0
index c804db7e90f8..5f82574236c0 100644

drivers/bluetooth/virtio_bt.c static int virtbt_add_inbuf(struct virtio_bluetooth *vbt) · line 41

Quoted 8 lines
drivers/bluetooth/virtio_bt.c +2 -0
@@ -34,6 +34,8 @@ static int virtbt_add_inbuf(struct virtio_bluetooth *vbt)
 	int err;
 
 	skb = alloc_skb(1000, GFP_KERNEL);
+	if (!skb)
+		return -ENOMEM;
 	sg_init_one(sg, skb->data, 1000);
 
 	err = virtqueue_add_inbuf(vq, sg, 1, skb, GFP_KERNEL);

a similar patch is already upstream in bluetooth-next.

Regards

Marcel