linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect()
@ 2019-07-29  9:04 Jia-Ju Bai
  2019-08-07 20:16 ` Bin Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2019-07-29  9:04 UTC (permalink / raw)
  To: b-liu, gregkh; +Cc: linux-usb, linux-kernel, Jia-Ju Bai

In musb_handle_intr_connect(), there is an if statement on line 783 to
check whether musb->hcd is NULL:
    if (musb->hcd)

When musb->hcd is NULL, it is used on line 797:
    musb_host_poke_root_hub(musb);
        if (musb->hcd->status_urb)

Thus, a possible null-pointer dereference may occur.

To fix this bug, musb->hcd is checked before calling
musb_host_poke_root_hub().

This bug is found by a static analysis tool STCheck written by us.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/usb/musb/musb_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 9f5a4819a744..329ff52f8167 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -794,7 +794,8 @@ static void musb_handle_intr_connect(struct musb *musb, u8 devctl, u8 int_usb)
 		break;
 	}
 
-	musb_host_poke_root_hub(musb);
+	if (musb->hcd)
+		musb_host_poke_root_hub(musb);
 
 	musb_dbg(musb, "CONNECT (%s) devctl %02x",
 			usb_otg_state_string(musb->xceiv->otg->state), devctl);
-- 
2.17.0


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

* Re: [PATCH] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect()
  2019-07-29  9:04 [PATCH] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect() Jia-Ju Bai
@ 2019-08-07 20:16 ` Bin Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Bin Liu @ 2019-08-07 20:16 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: gregkh, linux-usb, linux-kernel

On Mon, Jul 29, 2019 at 05:04:28PM +0800, Jia-Ju Bai wrote:
> In musb_handle_intr_connect(), there is an if statement on line 783 to
> check whether musb->hcd is NULL:
>     if (musb->hcd)
> 
> When musb->hcd is NULL, it is used on line 797:
>     musb_host_poke_root_hub(musb);
>         if (musb->hcd->status_urb)
> 
> Thus, a possible null-pointer dereference may occur.
> 
> To fix this bug, musb->hcd is checked before calling
> musb_host_poke_root_hub().
> 
> This bug is found by a static analysis tool STCheck written by us.
> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>

Applied. Thanks.

-Bin.


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

end of thread, other threads:[~2019-08-07 20:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29  9:04 [PATCH] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect() Jia-Ju Bai
2019-08-07 20:16 ` Bin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).