All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: Add missing null check
@ 2025-09-29 16:40 Andrew Goodbody
  2025-09-29 23:05 ` Marek Vasut
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrew Goodbody @ 2025-09-29 16:40 UTC (permalink / raw)
  To: Lukasz Majewski, Mattijs Korpershoek, Marek Vasut, Tom Rini
  Cc: Junhui Liu, Kongyang Liu, u-boot, Andrew Goodbody

Add in the missing null check for dev->driver that is present at other
points in the function before it is dereferenced.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
---
 drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
index fca052b4556a7d2ae4fe516e39820611d7082e2f..5a7f50ebaa5579f67ea5dc9491d0d1f4d4b81ea1 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
+++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
@@ -526,7 +526,7 @@ static int dwc2_udc_irq(int irq, void *_dev)
 		if (gotgint & GOTGINT_SES_END_DET) {
 			debug_cond(DEBUG_ISR, "\t\tSession End Detected\n");
 			/* Let gadget detect disconnected state */
-			if (dev->driver->disconnect) {
+			if (dev->driver && dev->driver->disconnect) {
 				spin_unlock_irqrestore(&dev->lock, flags);
 				dev->driver->disconnect(&dev->gadget);
 				spin_lock_irqsave(&dev->lock, flags);

---
base-commit: 9710d98e8942151fc0c62d54100d9d27e8263d04
change-id: 20250929-usb_dwc2-924d0d26df62

Best regards,
-- 
Andrew Goodbody <andrew.goodbody@linaro.org>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: dwc2: Add missing null check
  2025-09-29 16:40 [PATCH] usb: dwc2: Add missing null check Andrew Goodbody
@ 2025-09-29 23:05 ` Marek Vasut
  2025-09-30  7:51 ` Mattijs Korpershoek
  2025-09-30  9:54 ` Mattijs Korpershoek
  2 siblings, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2025-09-29 23:05 UTC (permalink / raw)
  To: Andrew Goodbody, Lukasz Majewski, Mattijs Korpershoek, Tom Rini
  Cc: Junhui Liu, Kongyang Liu, u-boot

On 9/29/25 6:40 PM, Andrew Goodbody wrote:
> Add in the missing null check for dev->driver that is present at other
> points in the function before it is dereferenced.
> 
> This issue was found by Smatch.
> 
> Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
> ---
>   drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> index fca052b4556a7d2ae4fe516e39820611d7082e2f..5a7f50ebaa5579f67ea5dc9491d0d1f4d4b81ea1 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> @@ -526,7 +526,7 @@ static int dwc2_udc_irq(int irq, void *_dev)
>   		if (gotgint & GOTGINT_SES_END_DET) {
>   			debug_cond(DEBUG_ISR, "\t\tSession End Detected\n");
>   			/* Let gadget detect disconnected state */
> -			if (dev->driver->disconnect) {
> +			if (dev->driver && dev->driver->disconnect) {

Reviewed-by: Marek Vasut <marek.vasut@mailbox.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: dwc2: Add missing null check
  2025-09-29 16:40 [PATCH] usb: dwc2: Add missing null check Andrew Goodbody
  2025-09-29 23:05 ` Marek Vasut
@ 2025-09-30  7:51 ` Mattijs Korpershoek
  2025-09-30  9:54 ` Mattijs Korpershoek
  2 siblings, 0 replies; 4+ messages in thread
From: Mattijs Korpershoek @ 2025-09-30  7:51 UTC (permalink / raw)
  To: Andrew Goodbody, Lukasz Majewski, Mattijs Korpershoek,
	Marek Vasut, Tom Rini
  Cc: Junhui Liu, Kongyang Liu, u-boot, Andrew Goodbody

Hi Andrew,

Thank you for the patch.

On Mon, Sep 29, 2025 at 17:40, Andrew Goodbody <andrew.goodbody@linaro.org> wrote:

> Add in the missing null check for dev->driver that is present at other
> points in the function before it is dereferenced.
>
> This issue was found by Smatch.
>
> Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

> ---
>  drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> index fca052b4556a7d2ae4fe516e39820611d7082e2f..5a7f50ebaa5579f67ea5dc9491d0d1f4d4b81ea1 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> @@ -526,7 +526,7 @@ static int dwc2_udc_irq(int irq, void *_dev)
>  		if (gotgint & GOTGINT_SES_END_DET) {
>  			debug_cond(DEBUG_ISR, "\t\tSession End Detected\n");
>  			/* Let gadget detect disconnected state */
> -			if (dev->driver->disconnect) {
> +			if (dev->driver && dev->driver->disconnect) {
>  				spin_unlock_irqrestore(&dev->lock, flags);
>  				dev->driver->disconnect(&dev->gadget);
>  				spin_lock_irqsave(&dev->lock, flags);
>
> ---
> base-commit: 9710d98e8942151fc0c62d54100d9d27e8263d04
> change-id: 20250929-usb_dwc2-924d0d26df62
>
> Best regards,
> -- 
> Andrew Goodbody <andrew.goodbody@linaro.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: dwc2: Add missing null check
  2025-09-29 16:40 [PATCH] usb: dwc2: Add missing null check Andrew Goodbody
  2025-09-29 23:05 ` Marek Vasut
  2025-09-30  7:51 ` Mattijs Korpershoek
@ 2025-09-30  9:54 ` Mattijs Korpershoek
  2 siblings, 0 replies; 4+ messages in thread
From: Mattijs Korpershoek @ 2025-09-30  9:54 UTC (permalink / raw)
  To: Lukasz Majewski, Marek Vasut, Tom Rini, Andrew Goodbody
  Cc: Junhui Liu, Kongyang Liu, u-boot

Hi,

On Mon, 29 Sep 2025 17:40:43 +0100, Andrew Goodbody wrote:
> Add in the missing null check for dev->driver that is present at other
> points in the function before it is dereferenced.
> 
> This issue was found by Smatch.
> 
> 

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu-next)

[1/1] usb: dwc2: Add missing null check
      https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/5ac61383b2db15b037e87bd353f726eafc49e181

--
Mattijs

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-30  9:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-29 16:40 [PATCH] usb: dwc2: Add missing null check Andrew Goodbody
2025-09-29 23:05 ` Marek Vasut
2025-09-30  7:51 ` Mattijs Korpershoek
2025-09-30  9:54 ` Mattijs Korpershoek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.