From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Prashanth K <prashanth.k@oss.qualcomm.com>
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 10:06:01 +0100 [thread overview]
Message-ID: <2025022434-unveiling-handbook-6fc3@gregkh> (raw)
In-Reply-To: <20250224085604.417327-1-prashanth.k@oss.qualcomm.com>
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
next prev parent reply other threads:[~2025-02-24 9:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 8:56 [PATCH] usb: gadget: Check bmAttributes only if configuration is valid Prashanth K
2025-02-24 9:06 ` Greg Kroah-Hartman [this message]
2025-02-24 9:23 ` Prashanth K
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=2025022434-unveiling-handbook-6fc3@gregkh \
--to=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=prashanth.k@oss.qualcomm.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