Skip to content

Commit df3334c

Browse files
Colin Ian Kinggregkh
authored andcommitted
usbip: vudc: fix null pointer dereference on udc->lock
Currently the driver attempts to spin lock on udc->lock before a NULL pointer check is performed on udc, hence there is a potential null pointer dereference on udc->lock. Fix this by moving the null check on udc before the lock occurs. Fixes: ea6873a ("usbip: vudc: Add SysFS infrastructure for VUDC") Signed-off-by: Colin Ian King <[email protected]> Acked-by: Shuah Khan <[email protected]> Reviewed-by: Krzysztof Opasiak <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 191edc5 commit df3334c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/usb/usbip/vudc_sysfs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,14 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
105105
if (rv != 0)
106106
return -EINVAL;
107107

108+
if (!udc) {
109+
dev_err(dev, "no device");
110+
return -ENODEV;
111+
}
108112
spin_lock_irqsave(&udc->lock, flags);
109113
/* Don't export what we don't have */
110-
if (!udc || !udc->driver || !udc->pullup) {
111-
dev_err(dev, "no device or gadget not bound");
114+
if (!udc->driver || !udc->pullup) {
115+
dev_err(dev, "gadget not bound");
112116
ret = -ENODEV;
113117
goto unlock;
114118
}

0 commit comments

Comments
 (0)