Skip to contentSkip to conversation

usb: musb: sunxi: Explicitly release USB PHY on exit

PATCH Applied Jonathan Liu 2 participants 6 messages Oct 10, 2017 – Oct 17, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: musb: sunxi: Explicitly release USB PHY on exit

This fixes a kernel oops when unloading the driver due to usb_put_phy being called after usb_phy_generic_unregister when the device is detached. Calling usb_phy_generic_unregister causes x->dev->driver to be NULL in usb_put_phy and results in a NULL pointer dereference.

---
Changes for v2:
- Use devm_usb_put_phy instead of usb_put_phy

 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/musb/sunxi.c +2 -0
index c9a09b5bb6e5..dc353e24d53c 100644
@@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb)
 	if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags))
 		sunxi_sram_release(musb->controller->parent);
 
+	devm_usb_put_phy(glue->dev, glue->xceiv);
+
 	return 0;
 }
 
Signature · 1 line
2.14.2
maintainer Applied
#1 lore raw
Quoted 19 lines · Jonathan Liu

This fixes a kernel oops when unloading the driver due to usb_put_phy being called after usb_phy_generic_unregister when the device is detached. Calling usb_phy_generic_unregister causes x->dev->driver to be NULL in usb_put_phy and results in a NULL pointer dereference.

Cc stable at vger.kernel.org # v4.3+

---
Changes for v2:
- Use devm_usb_put_phy instead of usb_put_phy

 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/musb/sunxi.c +0 -0
index c9a09b5bb6e5..dc353e24d53c 100644

drivers/usb/musb/sunxi.c static int sunxi_musb_exit(struct musb *musb) · line 303

Quoted 7 lines
drivers/usb/musb/sunxi.c +2 -0
@@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb)
 	if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags))
 		sunxi_sram_release(musb->controller->parent);
 
+	devm_usb_put_phy(glue->dev, glue->xceiv);
+
 	return 0;
 }

Applied. Thanks.
-Bin.

#2 lore raw
Quoted 23 lines · Bin Liu
Quoted 22 lines · Jonathan Liu

This fixes a kernel oops when unloading the driver due to usb_put_phy being called after usb_phy_generic_unregister when the device is detached. Calling usb_phy_generic_unregister causes x->dev->driver to be NULL in usb_put_phy and results in a NULL pointer dereference.

Cc stable at vger.kernel.org # v4.3+

---
Changes for v2:
- Use devm_usb_put_phy instead of usb_put_phy

 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/musb/sunxi.c +0 -0
index c9a09b5bb6e5..dc353e24d53c 100644
@@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb)
      if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags))
              sunxi_sram_release(musb->controller->parent);
 
Quoted 9 lines

drivers/usb/musb/sunxi.c static int sunxi_musb_exit(struct musb *musb) · line 303

Quoted 4 lines
drivers/usb/musb/sunxi.c +2 -0
+     devm_usb_put_phy(glue->dev, glue->xceiv);
+
      return 0;
 }

Applied. Thanks.
-Bin.

Which repository was it applied to?

Regards,
Jonathan

maintainer
#3 lore raw
Quoted 31 lines · Jonathan Liu
Quoted 29 lines · Bin Liu
Quoted 26 lines · Jonathan Liu

This fixes a kernel oops when unloading the driver due to usb_put_phy being called after usb_phy_generic_unregister when the device is detached. Calling usb_phy_generic_unregister causes x->dev->driver to be NULL in usb_put_phy and results in a NULL pointer dereference.

Cc stable at vger.kernel.org # v4.3+

---
Changes for v2:
- Use devm_usb_put_phy instead of usb_put_phy

 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/musb/sunxi.c +2 -0
index c9a09b5bb6e5..dc353e24d53c 100644
@@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb)
      if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags))
              sunxi_sram_release(musb->controller->parent);
 
+     devm_usb_put_phy(glue->dev, glue->xceiv);
+
      return 0;
 }
Quoted 4 lines
Quoted 2 lines

Applied. Thanks.
-Bin.

Which repository was it applied to?

I don't have a public repo (yet), but the patch has been sent to Greg, so it should be merged into the next -rc.

Regards,
-Bin.

#4 lore raw
Quoted 35 lines · Bin Liu
Quoted 34 lines · Jonathan Liu
Quoted 32 lines · Bin Liu
Quoted 19 lines · Jonathan Liu

This fixes a kernel oops when unloading the driver due to usb_put_phy being called after usb_phy_generic_unregister when the device is detached. Calling usb_phy_generic_unregister causes x->dev->driver to be NULL in usb_put_phy and results in a NULL pointer dereference.

Cc stable at vger.kernel.org # v4.3+

---
Changes for v2:
- Use devm_usb_put_phy instead of usb_put_phy

 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/musb/sunxi.c +0 -0
index c9a09b5bb6e5..dc353e24d53c 100644

drivers/usb/musb/sunxi.c static int sunxi_musb_exit(struct musb *musb) · line 303

Quoted 7 lines
drivers/usb/musb/sunxi.c +2 -0
@@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb)
      if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags))
              sunxi_sram_release(musb->controller->parent);
 
+     devm_usb_put_phy(glue->dev, glue->xceiv);
+
      return 0;
 }

Applied. Thanks.
-Bin.

Quoted 7 lines
Quoted 1 line

Which repository was it applied to?

I don't have a public repo (yet), but the patch has been sent to Greg, so it should be merged into the next -rc.

Regards,
-Bin.

The MAINTAINERS file has
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git listed as the tree for drivers/usb/musb/. I guess that should be updated.

Regards,
Jonathan

maintainer
#5 lore raw
Quoted 41 lines · Jonathan Liu
Quoted 40 lines · Bin Liu
Quoted 31 lines · Jonathan Liu
Quoted 29 lines · Bin Liu
Quoted 26 lines · Jonathan Liu

This fixes a kernel oops when unloading the driver due to usb_put_phy being called after usb_phy_generic_unregister when the device is detached. Calling usb_phy_generic_unregister causes x->dev->driver to be NULL in usb_put_phy and results in a NULL pointer dereference.

Cc stable at vger.kernel.org # v4.3+

---
Changes for v2:
- Use devm_usb_put_phy instead of usb_put_phy

 drivers/usb/musb/sunxi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/musb/sunxi.c +2 -0
index c9a09b5bb6e5..dc353e24d53c 100644
@@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb)
      if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags))
              sunxi_sram_release(musb->controller->parent);
 
+     devm_usb_put_phy(glue->dev, glue->xceiv);
+
      return 0;
 }
Quoted 4 lines
Quoted 2 lines

Applied. Thanks.
-Bin.

Which repository was it applied to?

I don't have a public repo (yet), but the patch has been sent to Greg, so it should be merged into the next -rc.

Quoted 6 lines
Quoted 2 lines

Regards,
-Bin.

The MAINTAINERS file has
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git listed as the tree for drivers/usb/musb/. I guess that should be updated.

I will create a patch for it. Thanks for reporting this.

Regards,
-Bin.