USB: usbtmc: remove unnecessary memory allocation
authorMing Lei <ming.lei@canonical.com>
Thu, 18 Apr 2013 04:17:38 +0000 (12:17 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Apr 2013 17:20:41 +0000 (10:20 -0700)
Inside usbtmc_ioctl_clear_out_halt()/usbtmc_ioctl_clear_in_halt(),
usb_clear_halt() needn't any buffer to pass in, so remove the
unnecessary memory allocation.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/usbtmc.c

index 70d69d06054f2faeaa1d4c9b2954d5cc0ca6e5b4..4c5506ae5e450db8a0977a618eb5e697bd6be1d0 100644 (file)
@@ -718,50 +718,32 @@ exit:
 
 static int usbtmc_ioctl_clear_out_halt(struct usbtmc_device_data *data)
 {
-       u8 *buffer;
        int rv;
 
-       buffer = kmalloc(2, GFP_KERNEL);
-       if (!buffer)
-               return -ENOMEM;
-
        rv = usb_clear_halt(data->usb_dev,
                            usb_sndbulkpipe(data->usb_dev, data->bulk_out));
 
        if (rv < 0) {
                dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n",
                        rv);
-               goto exit;
+               return rv;
        }
-       rv = 0;
-
-exit:
-       kfree(buffer);
-       return rv;
+       return 0;
 }
 
 static int usbtmc_ioctl_clear_in_halt(struct usbtmc_device_data *data)
 {
-       u8 *buffer;
        int rv;
 
-       buffer = kmalloc(2, GFP_KERNEL);
-       if (!buffer)
-               return -ENOMEM;
-
        rv = usb_clear_halt(data->usb_dev,
                            usb_rcvbulkpipe(data->usb_dev, data->bulk_in));
 
        if (rv < 0) {
                dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n",
                        rv);
-               goto exit;
+               return rv;
        }
-       rv = 0;
-
-exit:
-       kfree(buffer);
-       return rv;
+       return 0;
 }
 
 static int get_capabilities(struct usbtmc_device_data *data)