Message ID | 20241020-qcom_pmic_typec-fwnode_remove-v2-2-7054f3d2e215@gmail.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | usb: typec: qcom-pmic-typec: fix missing fwnode removal in error path | expand |
On Sun, Oct 20, 2024 at 02:56:35PM +0200, Javier Carrasco wrote: > If drm_dp_hpd_bridge_register() fails, the probe function returns > without removing the fwnode via fwnode_handle_put(), leaking the > resource. > > Jump to fwnode_remove if drm_dp_hpd_bridge_register() fails to remove > the fwnode acquired with device_get_named_child_node(). > > Cc: stable@vger.kernel.org > Fixes: 7d9f1b72b296 ("usb: typec: qcom-pmic-typec: switch to DRM_AUX_HPD_BRIDGE") > Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> > --- > drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
On 20/10/2024 13:56, Javier Carrasco wrote: > If drm_dp_hpd_bridge_register() fails, the probe function returns > without removing the fwnode via fwnode_handle_put(), leaking the > resource. > > Jump to fwnode_remove if drm_dp_hpd_bridge_register() fails to remove > the fwnode acquired with device_get_named_child_node(). > > Cc: stable@vger.kernel.org > Fixes: 7d9f1b72b296 ("usb: typec: qcom-pmic-typec: switch to DRM_AUX_HPD_BRIDGE") > Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> > --- > drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c > index 73a159e67ec2..3766790c1548 100644 > --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c > +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c > @@ -93,8 +93,10 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) > return -EINVAL; > > bridge_dev = devm_drm_dp_hpd_bridge_alloc(tcpm->dev, to_of_node(tcpm->tcpc.fwnode)); > - if (IS_ERR(bridge_dev)) > - return PTR_ERR(bridge_dev); > + if (IS_ERR(bridge_dev)) { > + ret = PTR_ERR(bridge_dev); > + goto fwnode_remove; > + } > > tcpm->tcpm_port = tcpm_register_port(tcpm->dev, &tcpm->tcpc); > if (IS_ERR(tcpm->tcpm_port)) { > Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
On Sun, Oct 20, 2024 at 02:56:35PM +0200, Javier Carrasco wrote: > If drm_dp_hpd_bridge_register() fails, the probe function returns > without removing the fwnode via fwnode_handle_put(), leaking the > resource. > > Jump to fwnode_remove if drm_dp_hpd_bridge_register() fails to remove > the fwnode acquired with device_get_named_child_node(). > > Cc: stable@vger.kernel.org > Fixes: 7d9f1b72b296 ("usb: typec: qcom-pmic-typec: switch to DRM_AUX_HPD_BRIDGE") > Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > --- > drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c > index 73a159e67ec2..3766790c1548 100644 > --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c > +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c > @@ -93,8 +93,10 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) > return -EINVAL; > > bridge_dev = devm_drm_dp_hpd_bridge_alloc(tcpm->dev, to_of_node(tcpm->tcpc.fwnode)); > - if (IS_ERR(bridge_dev)) > - return PTR_ERR(bridge_dev); > + if (IS_ERR(bridge_dev)) { > + ret = PTR_ERR(bridge_dev); > + goto fwnode_remove; > + } > > tcpm->tcpm_port = tcpm_register_port(tcpm->dev, &tcpm->tcpc); > if (IS_ERR(tcpm->tcpm_port)) { > > -- > 2.43.0
diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c index 73a159e67ec2..3766790c1548 100644 --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c @@ -93,8 +93,10 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev) return -EINVAL; bridge_dev = devm_drm_dp_hpd_bridge_alloc(tcpm->dev, to_of_node(tcpm->tcpc.fwnode)); - if (IS_ERR(bridge_dev)) - return PTR_ERR(bridge_dev); + if (IS_ERR(bridge_dev)) { + ret = PTR_ERR(bridge_dev); + goto fwnode_remove; + } tcpm->tcpm_port = tcpm_register_port(tcpm->dev, &tcpm->tcpc); if (IS_ERR(tcpm->tcpm_port)) {
If drm_dp_hpd_bridge_register() fails, the probe function returns without removing the fwnode via fwnode_handle_put(), leaking the resource. Jump to fwnode_remove if drm_dp_hpd_bridge_register() fails to remove the fwnode acquired with device_get_named_child_node(). Cc: stable@vger.kernel.org Fixes: 7d9f1b72b296 ("usb: typec: qcom-pmic-typec: switch to DRM_AUX_HPD_BRIDGE") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> --- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)