From: Shuah Khan <shuah@kernel.org>
To: Colin King <colin.king@canonical.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
Shuah Khan <shuahkh@osg.samsung.com>,
Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH] usbip: vudc: fix null pointer dereference on udc->lock
Date: Mon, 26 Feb 2018 09:40:25 -0700 [thread overview]
Message-ID: <0e3059a0-1310-5d08-4623-f1cf34c52fc0@kernel.org> (raw)
In-Reply-To: <20180222173917.10841-1-colin.king@canonical.com>
On 02/22/2018 10:39 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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: ea6873a45a22 ("usbip: vudc: Add SysFS infrastructure for VUDC")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/usb/usbip/vudc_sysfs.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
> index d86f72bbbb91..6dcd3ff655c3 100644
> --- a/drivers/usb/usbip/vudc_sysfs.c
> +++ b/drivers/usb/usbip/vudc_sysfs.c
> @@ -105,10 +105,14 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
> if (rv != 0)
> return -EINVAL;
>
> + if (!udc) {
> + dev_err(dev, "no device");
> + return -ENODEV;
> + }
> spin_lock_irqsave(&udc->lock, flags);
> /* Don't export what we don't have */
> - if (!udc || !udc->driver || !udc->pullup) {
> - dev_err(dev, "no device or gadget not bound");
> + if (!udc->driver || !udc->pullup) {
> + dev_err(dev, "gadget not bound");
> ret = -ENODEV;
> goto unlock;
> }
>
Thanks for the patch. Looks good to me.
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
thanks,
-- Shuah
next prev parent reply other threads:[~2018-02-26 16:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-22 17:39 Colin King
2018-02-26 16:40 ` Shuah Khan [this message]
2018-02-27 13:24 ` Krzysztof Opasiak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0e3059a0-1310-5d08-4623-f1cf34c52fc0@kernel.org \
--to=shuah@kernel.org \
--cc=colin.king@canonical.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=shuahkh@osg.samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®