Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 086ebf92 authored by Weitao Hou's avatar Weitao Hou Committed by Greg Kroah-Hartman
Browse files

usb: avoid redundant allocation and free of memory



If usb is not attached, it's unnessary to allocate, copy
and free memory

Signed-off-by: default avatarWeitao Hou <houweitaoo@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6e9aed4e
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -2130,6 +2130,9 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl)
	if (ps->privileges_dropped)
		return -EACCES;

	if (!connected(ps))
		return -ENODEV;

	/* alloc buffer */
	size = _IOC_SIZE(ctl->ioctl_code);
	if (size > 0) {
@@ -2146,11 +2149,6 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl)
		}
	}

	if (!connected(ps)) {
		kfree(buf);
		return -ENODEV;
	}

	if (ps->dev->state != USB_STATE_CONFIGURED)
		retval = -EHOSTUNREACH;
	else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno)))