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
2130 if (ps->privileges_dropped)2130 if (ps->privileges_dropped)
2131 return -EACCES;2131 return -EACCES;
2132 2132
2133 if (!connected(ps))
2134 return -ENODEV;
2135
2133 /* alloc buffer */2136 /* alloc buffer */
2134 size = _IOC_SIZE(ctl->ioctl_code);2137 size = _IOC_SIZE(ctl->ioctl_code);
2135 if (size > 0) {2138 if (size > 0) {
@@ -2146,11 +2149,6 @@ static int proc_ioctl(struct usb_dev_state *ps, struct usbdevfs_ioctl *ctl) · 10 unmodified lines
2146 }2149 }
2147 }2150 }
2148 2151
2149 if (!connected(ps)) {
2150 kfree(buf);
2151 return -ENODEV;
2152 }
2153
2154 if (ps->dev->state != USB_STATE_CONFIGURED)2152 if (ps->dev->state != USB_STATE_CONFIGURED)
2155 retval = -EHOSTUNREACH;2153 retval = -EHOSTUNREACH;
2156 else if (!(intf = usb_ifnum_to_if(ps->dev, ctl->ifno)))2154 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