瀏覽代碼

[media] cx231xx: correctly handling failed allocation

Since kmalloc can be failed in memory pressure,
if not properly handled, NULL dereference can be happend

Signed-off-by: Insu Yun <wuninsu@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Insu Yun 9 年之前
父節點
當前提交
f8433226d1
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      drivers/media/usb/cx231xx/cx231xx-417.c

+ 2 - 0
drivers/media/usb/cx231xx/cx231xx-417.c

@@ -1382,6 +1382,8 @@ static int cx231xx_bulk_copy(struct cx231xx *dev, struct urb *urb)
 	buffer_size = urb->actual_length;
 
 	buffer = kmalloc(buffer_size, GFP_ATOMIC);
+	if (!buffer)
+		return -ENOMEM;
 
 	memcpy(buffer, dma_q->ps_head, 3);
 	memcpy(buffer+3, p_buffer, buffer_size-3);