Commit df3334c2 authored by Colin Ian King's avatar Colin Ian King Committed by Greg Kroah-Hartman

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: ea6873a4 ("usbip: vudc: Add SysFS infrastructure for VUDC")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
Reviewed-by: default avatarKrzysztof Opasiak <k.opasiak@samsung.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 191edc5e
...@@ -105,10 +105,14 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a ...@@ -105,10 +105,14 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
if (rv != 0) if (rv != 0)
return -EINVAL; return -EINVAL;
if (!udc) {
dev_err(dev, "no device");
return -ENODEV;
}
spin_lock_irqsave(&udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
/* Don't export what we don't have */ /* Don't export what we don't have */
if (!udc || !udc->driver || !udc->pullup) { if (!udc->driver || !udc->pullup) {
dev_err(dev, "no device or gadget not bound"); dev_err(dev, "gadget not bound");
ret = -ENODEV; ret = -ENODEV;
goto unlock; goto unlock;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment