phy: qcom: qmp-usb: fix NULL-deref on runtime suspend
Subsystems (3)
cover phy: qcom: qmp-usb: fix NULL-deref on runtime suspend
When working on suspend support for Qualcomm platforms like x1e80100, I ran into a NULL-pointer dereference in one of the QMP drivers. Turns out this issue has since been reproduced in two more drivers.
Johan
Johan Hovold (4):
phy: qcom: qmp-usb: fix NULL-deref on runtime suspend
phy: qcom: qmp-usb-legacy: fix NULL-deref on runtime suspend
phy: qcom: qmp-usbc: fix NULL-deref on runtime suspend
phy: qcom: qmp-usb: move driver data initialisation earlier
drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 3 +-- drivers/phy/qualcomm/phy-qcom-qmp-usb-legacy.c | 1 + drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 1 + drivers/phy/qualcomm/phy-qcom-qmp-usbc.c | 1 + 4 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.44.2
PATCH 1/4 phy: qcom: qmp-usb: fix NULL-deref on runtime suspend
Commit 413db06c05e7 ("phy: qcom-qmp-usb: clean up probe initialisation") removed most users of the platform device driver data, but mistakenly also removed the initialisation despite the data still being used in the runtime PM callbacks.
Restore the driver data initialisation at probe to avoid a NULL-pointer dereference on runtime suspend.
Apparently no one uses runtime PM, which currently needs to be enabled manually through sysfs, with this driver.
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +1 -0
@@ -2191,6 +2191,7 @@ static int qmp_usb_probe(struct platform_device *pdev)return -ENOMEM ; qmp->dev = dev; +dev_set_drvdata (dev, qmp); qmp->cfg =of_device_get_match_data (dev);if (!qmp->cfg)
Signature · 1 line
2.44.2
PATCH 2/4 phy: qcom: qmp-usb-legacy: fix NULL-deref on runtime suspend
In reply to Johan HovoldCommit 413db06c05e7 ("phy: qcom-qmp-usb: clean up probe initialisation") removed most users of the platform device driver data from the qcom-qmp-usb driver, but mistakenly also removed the initialisation despite the data still being used in the runtime PM callbacks. This bug was later reproduced when the driver was copied to create the qmp-usb-legacy driver.
Restore the driver data initialisation at probe to avoid a NULL-pointer dereference on runtime suspend.
Apparently no one uses runtime PM, which currently needs to be enabled manually through sysfs, with these drivers.
--- drivers/phy/qualcomm/phy-qcom-qmp-usb-legacy.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/qualcomm/phy-qcom-qmp-usb-legacy.c +1 -0
@@ -1248,6 +1248,7 @@ static int qmp_usb_legacy_probe(struct platform_device *pdev)return -ENOMEM ; qmp->dev = dev; +dev_set_drvdata (dev, qmp); qmp->cfg =of_device_get_match_data (dev);if (!qmp->cfg)
Signature · 1 line
2.44.2
PATCH 3/4 phy: qcom: qmp-usbc: fix NULL-deref on runtime suspend
In reply to Johan HovoldCommit 413db06c05e7 ("phy: qcom-qmp-usb: clean up probe initialisation") removed most users of the platform device driver data from the qcom-qmp-usb driver, but mistakenly also removed the initialisation despite the data still being used in the runtime PM callbacks. This bug was later reproduced when the driver was copied to create the qmp-usbc driver.
Restore the driver data initialisation at probe to avoid a NULL-pointer dereference on runtime suspend.
Apparently no one uses runtime PM, which currently needs to be enabled manually through sysfs, with these drivers.
--- drivers/phy/qualcomm/phy-qcom-qmp-usbc.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/qualcomm/phy-qcom-qmp-usbc.c +1 -0
@@ -1049,6 +1049,7 @@ static int qmp_usbc_probe(struct platform_device *pdev)return -ENOMEM ; qmp->dev = dev; +dev_set_drvdata (dev, qmp); qmp->orientation =TYPEC_ORIENTATION_NORMAL ;
Signature · 1 line
2.44.2
PATCH 4/4 phy: qcom: qmp-usb: move driver data initialisation earlier
In reply to Johan HovoldCommit 44aff8e31080 ("phy: qcom-qmp-combo: clean up probe initialisation") removed most users of the platform device driver data, but mistakenly also removed the initialisation despite the data still being used in the runtime PM callbacks.
The initialisation was soon after restored by commit 83a0bbe39b17 ("phy:
qcom-qmp-combo: add support for updated sc8280xp binding") but now happens slightly later during probe. This should not cause any trouble currently as runtime PM needs to be enabled manually through sysfs and the platform device would not be suspended before the PHY has been registered anyway.
Move the driver data initialisation to avoid a NULL-pointer dereference on runtime suspend if runtime PM is ever enabled by default in this driver.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +1 -2
@@ -3649,6 +3649,7 @@ static int qmp_combo_probe(struct platform_device *pdev)return -ENOMEM ; qmp->dev = dev; +dev_set_drvdata (dev, qmp); qmp->orientation =TYPEC_ORIENTATION_NORMAL ;
@@ -3725,8 +3726,6 @@ static int qmp_combo_probe(struct platform_device *pdev)phy_set_drvdata (qmp->dp_phy, qmp); -dev_set_drvdata (dev, qmp); -if (usb_np == dev->of_node) phy_provider =devm_of_phy_provider_register (dev, qmp_combo_phy_xlate);else
Signature · 1 line
2.44.2
Re: [PATCH 4/4] phy: qcom: qmp-usb: move driver data initialisation earlier
Quoted 4 lines · Johan Hovold
Commit
44aff8e31080("phy: qcom-qmp-combo: clean up probe initialisation") removed most users of the platform device driver data, but mistakenly also removed the initialisation despite the data still being used in the runtime PM callbacks.
Perhaps the copy/paste error in Subject can be fixed when applying. The summary was supposed to say:
phy: qcom: qmp-combo: move driver data initialisation earlier
and nothing else.
Johan
Quoted 5 lines · Johan Hovold
When working on suspend support for Qualcomm platforms like x1e80100, I ran into a NULL-pointer dereference in one of the QMP drivers. Turns out this issue has since been reproduced in two more drivers.
Johan
For the series:
Signature · 2 lines
With best wishes Dmitry
Hi Vinod,
Quoted 9 lines · Johan Hovold
When working on suspend support for Qualcomm platforms like x1e80100, I ran into a NULL-pointer dereference in one of the QMP drivers. Turns out this issue has since been reproduced in two more drivers.
Johan Hovold (4):
phy: qcom: qmp-usb: fix NULL-deref on runtime suspend
phy: qcom: qmp-usb-legacy: fix NULL-deref on runtime suspend
phy: qcom: qmp-usbc: fix NULL-deref on runtime suspend
phy: qcom: qmp-usb: move driver data initialisation earlier
It's been a month (and a merge window) so sending a reminder.
Could you pick these up for 6.12-rc?
Johan
Quoted 8 lines · Johan Hovold
When working on suspend support for Qualcomm platforms like x1e80100, I ran into a NULL-pointer dereference in one of the QMP drivers. Turns out this issue has since been reproduced in two more drivers.
Johan
[...]
Applied, thanks!
[1/4] phy: qcom: qmp-usb: fix NULL-deref on runtime suspend
commit: bd9e4d4a3b127686efc60096271b0a44c3100061
[2/4] phy: qcom: qmp-usb-legacy: fix NULL-deref on runtime suspend
commit: 29240130ab77c80bea1464317ae2a5fd29c16a0c
[3/4] phy: qcom: qmp-usbc: fix NULL-deref on runtime suspend
commit: 34c21f94fa1e147a19b54b6adf0c93a623b70dd8
[4/4] phy: qcom: qmp-usb: move driver data initialisation earlier
commit: 1dd196f9004848d0318e8831f962cc76255431d8Best regards,
Signature · 1 line
~Vinod