Skip to contentSkip to conversation

musb fixes for v5.5-rc2

PATCH In review Bin Liu 4 participants 11 messages Dec 10, 2019 – Dec 17, 2019

Subsystems (3)
lore
Share & tools
lore

Bin Liu

author maintainer
#0 lore raw

cover musb fixes for v5.5-rc2

Hi Greg,

Here are couple patches for musb fixes for v5.5 -rc. Please let me know if any change is needed.

Regards,
-Bin.
---

Jia-Ju Bai (1):
usb: musb: Fix a possible null-pointer dereference in
musb_handle_intr_connect()

Mans Rullgard (1):
usb: musb: sunxi: propagate devicetree node to glue pdev

 drivers/usb/musb/musb_core.c | 3 ++-
 drivers/usb/musb/sunxi.c     | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH 1/2 usb: musb: sunxi: propagate devicetree node to glue pdev

From: Mans Rullgard <[email protected]>

In order for devicetree nodes to be correctly associated with attached devices, the controller node needs to be propagated to the glue device.

---
 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/musb/sunxi.c +2 -0
index 832a41f9ee7d..a72665fbf111 100644
@@ -781,6 +781,8 @@ static int sunxi_musb_probe(struct platform_device *pdev)
 	pinfo.name	 = "musb-hdrc";
 	pinfo.id	= PLATFORM_DEVID_AUTO;
 	pinfo.parent	= &pdev->dev;
+	pinfo.fwnode	= of_fwnode_handle(pdev->dev.of_node);
+	pinfo.of_node_reused = true;
 	pinfo.res	= pdev->resource;
 	pinfo.num_res	= pdev->num_resources;
 	pinfo.data	= &pdata;
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/2] usb: musb: sunxi: propagate devicetree node to glue pdev

Quoted 10 lines · Bin Liu

From: Mans Rullgard <[email protected]>

In order for devicetree nodes to be correctly associated with attached devices, the controller node needs to be propagated to the glue device.

---
 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)

Does this need to go to stable kernel(s)? If so, what commit does this fix fix?

thanks,

greg k-h

#3 lore raw

Re: [PATCH 1/2] usb: musb: sunxi: propagate devicetree node to glue pdev

Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · Bin Liu

From: Mans Rullgard <[email protected]>

In order for devicetree nodes to be correctly associated with attached devices, the controller node needs to be propagated to the glue device.

Quoted 8 lines
Quoted 5 lines
---
 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)

Does this need to go to stable kernel(s)? If so, what commit does this fix fix?

No, I'd say it's a new feature.

Johan

#4 lore raw

Re: [PATCH 1/2] usb: musb: sunxi: propagate devicetree node to glue pdev

Quoted 13 lines · Johan Hovold
Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · Bin Liu

From: Mans Rullgard <[email protected]>

In order for devicetree nodes to be correctly associated with attached devices, the controller node needs to be propagated to the glue device.

---
 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 4 lines
Quoted 2 lines

Does this need to go to stable kernel(s)? If so, what commit does this fix fix?

No, I'd say it's a new feature.

Then why is it needed for 5.5-final and not for 5.6-rc1?

thanks,

greg k-h

#5 lore raw

Re: [PATCH 1/2] usb: musb: sunxi: propagate devicetree node to glue pdev

Quoted 14 lines · Greg Kroah-Hartman
Quoted 13 lines · Johan Hovold
Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · Bin Liu

From: Mans Rullgard <[email protected]>

In order for devicetree nodes to be correctly associated with attached devices, the controller node needs to be propagated to the glue device.

---
 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Does this need to go to stable kernel(s)? If so, what commit does this fix fix?

No, I'd say it's a new feature.

Then why is it needed for 5.5-final and not for 5.6-rc1?

Right, it shouldn't be needed in 5.5.

Johan

author maintainer
#6 lore raw

PATCH 2/2 usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect()

In reply to Bin Liu

From: Jia-Ju Bai <[email protected]>

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.

---
 drivers/usb/musb/musb_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/musb/musb_core.c +2 -1
index 15cca912c53e..5080fc6a0808 100644
@@ -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);
Signature · 1 line
2.17.1
#7 lore raw

Re: [PATCH 2/2] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect()

Quoted 11 lines · Bin Liu

From: Jia-Ju Bai <[email protected]>

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.

Maybe, if musb->hcd really ever could be NULL.

In looking at the code, I don't see where that could happen, do you? Why is that check there in the first place?

What sets musb->hcd to NULL in the first place?

thanks,

greg k-h

#8 lore raw

Re: [PATCH 2/2] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect()

Quoted 11 lines · Greg Kroah-Hartman
Quoted 10 lines · Bin Liu

From: Jia-Ju Bai <[email protected]>

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)
Quoted 7 lines
Quoted 1 line

Thus, a possible null-pointer dereference may occur.

Maybe, if musb->hcd really ever could be NULL.

In looking at the code, I don't see where that could happen, do you? Why is that check there in the first place?

What sets musb->hcd to NULL in the first place?

In fact, my static analysis tool identifies an if check about musb->hcd, so it infers that musb->hcd could be NULL here. But it does not try to find any explicit place that set musb->hcd to NULL.

If musb->hcd is never NULL here, we can just delete the related if check.

Best wishes,
Jia-Ju Bai

#9 lore raw

Re: [PATCH 2/2] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect()

Quoted 17 lines · Jia-Ju Bai
Quoted 14 lines · Greg Kroah-Hartman
Quoted 11 lines · Bin Liu

From: Jia-Ju Bai <[email protected]>

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.

Maybe, if musb->hcd really ever could be NULL.

Quoted 8 lines
Quoted 4 lines

In looking at the code, I don't see where that could happen, do you? Why is that check there in the first place?

What sets musb->hcd to NULL in the first place?

In fact, my static analysis tool identifies an if check about musb->hcd, so it infers that musb->hcd could be NULL here.
But it does not try to find any explicit place that set musb->hcd to NULL.

Can it do that?

Quoted 1 line

If musb->hcd is never NULL here, we can just delete the related if check.

I agree :)

thanks,

greg k-h

#10 lore raw

Re: [PATCH 2/2] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect()

Quoted 17 lines · Greg Kroah-Hartman
Quoted 16 lines · Jia-Ju Bai
Quoted 14 lines · Greg Kroah-Hartman
Quoted 11 lines · Bin Liu

From: Jia-Ju Bai <[email protected]>

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.

Maybe, if musb->hcd really ever could be NULL.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

In looking at the code, I don't see where that could happen, do you? Why is that check there in the first place?

What sets musb->hcd to NULL in the first place?

In fact, my static analysis tool identifies an if check about musb->hcd, so it infers that musb->hcd could be NULL here.
But it does not try to find any explicit place that set musb->hcd to NULL.

Can it do that?

Not yet...

Quoted 3 lines
Quoted 2 lines

If musb->hcd is never NULL here, we can just delete the related if check.

I agree :)

Okay, I will send a new patch that delete the if check.

Best wishes,
Jia-Ju Bai