Commit ac9e59ca authored by Ming Lei's avatar Ming Lei Committed by Greg Kroah-Hartman

USB: usbtmc: remove unnecessary memory allocation

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: default avatarMing Lei <ming.lei@canonical.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c33c888b
...@@ -718,50 +718,32 @@ static int usbtmc_ioctl_clear(struct usbtmc_device_data *data) ...@@ -718,50 +718,32 @@ static int usbtmc_ioctl_clear(struct usbtmc_device_data *data)
static int usbtmc_ioctl_clear_out_halt(struct usbtmc_device_data *data) static int usbtmc_ioctl_clear_out_halt(struct usbtmc_device_data *data)
{ {
u8 *buffer;
int rv; int rv;
buffer = kmalloc(2, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
rv = usb_clear_halt(data->usb_dev, rv = usb_clear_halt(data->usb_dev,
usb_sndbulkpipe(data->usb_dev, data->bulk_out)); usb_sndbulkpipe(data->usb_dev, data->bulk_out));
if (rv < 0) { if (rv < 0) {
dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n", dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n",
rv); rv);
goto exit; return rv;
} }
rv = 0; return 0;
exit:
kfree(buffer);
return rv;
} }
static int usbtmc_ioctl_clear_in_halt(struct usbtmc_device_data *data) static int usbtmc_ioctl_clear_in_halt(struct usbtmc_device_data *data)
{ {
u8 *buffer;
int rv; int rv;
buffer = kmalloc(2, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
rv = usb_clear_halt(data->usb_dev, rv = usb_clear_halt(data->usb_dev,
usb_rcvbulkpipe(data->usb_dev, data->bulk_in)); usb_rcvbulkpipe(data->usb_dev, data->bulk_in));
if (rv < 0) { if (rv < 0) {
dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n", dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n",
rv); rv);
goto exit; return rv;
} }
rv = 0; return 0;
exit:
kfree(buffer);
return rv;
} }
static int get_capabilities(struct usbtmc_device_data *data) static int get_capabilities(struct usbtmc_device_data *data)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment