Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: em28xx: Fix exception handling in em28xx_alloc_urbs()

A null pointer would be passed to a call of the function "kfree" directly
after a call of the function "kcalloc" failed at one place.
Pass the data structure member "urb" instead for which memory
was allocated before (so that this resource will be properly cleaned up).

This issue was detected by using the Coccinelle software.

Fixes: d571b592c6206d33731f41aa710fa0f69ac8611b ("media: em28xx: don't use coherent buffer for DMA transfers")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

authored by

Markus Elfring and committed by
Mauro Carvalho Chehab
ecbce48f 95c52069

+1 -1
+1 -1
drivers/media/usb/em28xx/em28xx-core.c
··· 931 931 932 932 usb_bufs->buf = kcalloc(num_bufs, sizeof(void *), GFP_KERNEL); 933 933 if (!usb_bufs->buf) { 934 - kfree(usb_bufs->buf); 934 + kfree(usb_bufs->urb); 935 935 return -ENOMEM; 936 936 } 937 937