If usb is not attached, it's unnessary to allocate, copy and free memory
Unified · Split
| @@ -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))) |