From: Dan Carpenter Date: Wed, 30 Jan 2013 06:03:43 +0000 (-0300) Subject: [media] tm6000: check an allocation for failure X-Git-Tag: v3.9-rc5~2^2~47 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88b404c435ffb6c103faf85cc1b41077dcd03bf9;p=platform%2Fkernel%2Flinux-stable.git [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 Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/usb/tm6000/tm6000-core.c b/drivers/media/usb/tm6000/tm6000-core.c index 22cc011..7c32353 100644 --- a/drivers/media/usb/tm6000/tm6000-core.c +++ b/drivers/media/usb/tm6000/tm6000-core.c @@ -40,10 +40,13 @@ int tm6000_read_write_usb(struct tm6000_core *dev, u8 req_type, u8 req, u8 *data = NULL; int delay = 5000; - mutex_lock(&dev->usb_lock); - - if (len) + if (len) { data = kzalloc(len, GFP_KERNEL); + if (!data) + return -ENOMEM; + } + + mutex_lock(&dev->usb_lock); if (req_type & USB_DIR_IN) pipe = usb_rcvctrlpipe(dev->udev, 0);