History

usb: avoid redundant allocation and free of memory

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

Weitao Hou committed 7 years ago

Commit 086ebf91 parent 6e9aed41 file · +3 −5Browse files

Unified · Split

drivers/usb/core/devio.c+3−5
@@ -2130,6 +2130,9 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) · 2129 unmodified lines
21302130 if (ps->privileges_dropped)
21312131 return -EACCES;
21322132
2133+ if (!connected(ps))
2134+ return -ENODEV;
2135+
21332136 /* alloc buffer */
21342137 size = _IOC_SIZE(ctl->ioctl_code);
21352138 if (size > 0) {
@@ -2146,11 +2149,6 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) · 10 unmodified lines
21462149 }
21472150 }
21482151
2149− if (!connected(ps)) {
2150− kfree(buf);
2151− return -ENODEV;
2152− }
2153−
21542152 if (ps->dev->state != USB_STATE_CONFIGURED)
21552153 retval = -EHOSTUNREACH;
21562154 else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno)))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t