Skip to content

Commit d80eee9

Browse files
jhovoldgregkh
authored andcommitted
usb: typec: qcom-pmic: fix use-after-free on late probe errors
Make sure to stop and deregister the port in case of late probe errors to avoid use-after-free issues when the underlying memory is released by devres. Fixes: a4422ff ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver") Cc: stable@vger.kernel.org # 6.5 Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20240418145730.4605-2-johan+linaro@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0aea736 commit d80eee9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,18 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
104104

105105
ret = tcpm->port_start(tcpm, tcpm->tcpm_port);
106106
if (ret)
107-
goto fwnode_remove;
107+
goto port_unregister;
108108

109109
ret = tcpm->pdphy_start(tcpm, tcpm->tcpm_port);
110110
if (ret)
111-
goto fwnode_remove;
111+
goto port_stop;
112112

113113
return 0;
114114

115+
port_stop:
116+
tcpm->port_stop(tcpm);
117+
port_unregister:
118+
tcpm_unregister_port(tcpm->tcpm_port);
115119
fwnode_remove:
116120
fwnode_remove_software_node(tcpm->tcpc.fwnode);
117121

0 commit comments

Comments
 (0)