diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2013-01-30 03:03:43 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-02-08 14:46:56 -0200 |
commit | 88b404c435ffb6c103faf85cc1b41077dcd03bf9 (patch) | |
tree | c055dd6d58c0168a057b6ae09e6a4e9af72806ae | |
parent | de03277d6ae26d09b3af8617f291c4bb3db7d2eb (diff) | |
download | linux-88b404c435ffb6c103faf85cc1b41077dcd03bf9.tar.gz linux-88b404c435ffb6c103faf85cc1b41077dcd03bf9.tar.bz2 linux-88b404c435ffb6c103faf85cc1b41077dcd03bf9.zip |
[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>
-rw-r--r-- | drivers/media/usb/tm6000/tm6000-core.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/media/usb/tm6000/tm6000-core.c b/drivers/media/usb/tm6000/tm6000-core.c index 22cc0116deb6..7c32353c59db 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); |