From: Insu Yun Date: Tue, 29 Dec 2015 18:53:35 +0000 (-0200) Subject: [media] cx231xx: correctly handling failed allocation X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f8433226d1b3eb035693724dca786c4445221368;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [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 Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c index 48643b94e694..c9320d6c6131 100644 --- a/drivers/media/usb/cx231xx/cx231xx-417.c +++ b/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);