From: Krzysztof Opasiak <k.opasiak@samsung.com>
To: shuah@kernel.org, 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>
Subject: Re: [PATCH] usbip: vudc: fix null pointer dereference on udc->lock
Date: Tue, 27 Feb 2018 14:24:44 +0100 [thread overview]
Message-ID: <b021604f-06e0-e595-23c5-cf40e7a02268@samsung.com> (raw)
In-Reply-To: <0e3059a0-1310-5d08-4623-f1cf34c52fc0@kernel.org>
On 02/26/2018 05:40 PM, Shuah Khan wrote:
> 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>
Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
but you could fix also a similar bug one one function above
(dev_desc_read()) ;)
Best regards,
--
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
prev parent reply other threads:[~2018-02-27 13:24 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
2018-02-27 13:24 ` Krzysztof Opasiak [this message]
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=b021604f-06e0-e595-23c5-cf40e7a02268@samsung.com \
--to=k.opasiak@samsung.com \
--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=shuah@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®