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

[media] tm6000: check an allocation for failure

This allocation had no error checking. It didn't need to be under
the mutex so I moved it out form there. That makes the error handling
easier and is a potential speed up.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Dan Carpenter and committed by
Mauro Carvalho Chehab
88b404c4 de03277d

+6 -3
+6 -3
drivers/media/usb/tm6000/tm6000-core.c
··· 40 40 u8 *data = NULL; 41 41 int delay = 5000; 42 42 43 - mutex_lock(&dev->usb_lock); 44 - 45 - if (len) 43 + if (len) { 46 44 data = kzalloc(len, GFP_KERNEL); 45 + if (!data) 46 + return -ENOMEM; 47 + } 48 + 49 + mutex_lock(&dev->usb_lock); 47 50 48 51 if (req_type & USB_DIR_IN) 49 52 pipe = usb_rcvctrlpipe(dev->udev, 0);