mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Prashanth K <prashanth.k@oss.qualcomm.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Kees Bakker <kees@ijzerbout.nl>,
	William McVicker <willmcvicker@google.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: Check bmAttributes only if configuration is valid
Date: Mon, 24 Feb 2025 14:53:59 +0530	[thread overview]
Message-ID: <63c3b650-c3cf-49bc-973a-c5fe025a22f6@oss.qualcomm.com> (raw)
In-Reply-To: <2025022434-unveiling-handbook-6fc3@gregkh>



On 24-02-25 02:36 pm, Greg Kroah-Hartman wrote:
> On Mon, Feb 24, 2025 at 02:26:04PM +0530, Prashanth K wrote:
>> If the USB configuration is not valid, then avoid checking for
>> bmAttributes to prevent null pointer deference.
>>
>> Cc: stable@vger.kernel.org
>> Fixes: 40e89ff5750f ("usb: gadget: Set self-powered based on MaxPower and bmAttributes")
>> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
>> ---
>>  drivers/usb/gadget/composite.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
>> index 4bcf73bae761..869ad99afb48 100644
>> --- a/drivers/usb/gadget/composite.c
>> +++ b/drivers/usb/gadget/composite.c
>> @@ -1051,7 +1051,7 @@ static int set_config(struct usb_composite_dev *cdev,
>>  		usb_gadget_set_remote_wakeup(gadget, 0);
>>  done:
>>  	if (power > USB_SELF_POWER_VBUS_MAX_DRAW ||
>> -	    !(c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
>> +	    (c && !(c->bmAttributes & USB_CONFIG_ATT_SELFPOWER)))
>>  		usb_gadget_clear_selfpowered(gadget);
>>  	else
>>  		usb_gadget_set_selfpowered(gadget);
>> -- 
>> 2.25.1
>>
>>
> 
> Have you checked linux-next yet for this fix that was posted last week?
> Does that not resolve the issue for you?
> 
> thanks,
> 
> greg k-h

I hope you are mentioning this one -
https://lore.kernel.org/all/20250220120314.3614330-1-m.szyprowski@samsung.com/

The above patch fixes null pointer in composite_suspend(), I'm trying to
address a similar bug which is present in set_config(), it gets exposed
if the requested configuration is not present in cdev->configs.

Regards,
Prashanth K

  reply	other threads:[~2025-02-24  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24  8:56 Prashanth K
2025-02-24  9:06 ` Greg Kroah-Hartman
2025-02-24  9:23   ` Prashanth K [this message]
2025-02-24  9:51     ` Greg Kroah-Hartman

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=63c3b650-c3cf-49bc-973a-c5fe025a22f6@oss.qualcomm.com \
    --to=prashanth.k@oss.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kees@ijzerbout.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=stable@vger.kernel.org \
    --cc=willmcvicker@google.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®