* [PATCH v3] soc: qcom: pmic: Fix resource leaks in a device_for_each_child_node() loop
@ 2023-06-12 13:34 Lu Hongfei
2023-09-19 23:07 ` Bjorn Andersson
2023-12-03 17:46 ` David Heidelberg
0 siblings, 2 replies; 4+ messages in thread
From: Lu Hongfei @ 2023-06-12 13:34 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio,
open list:ARM/QUALCOMM SUPPORT, open list
Cc: opensource.kernel, luhongfei
The device_for_each_child_node loop should call fwnode_handle_put()
before return in some error cases, which could avoid resource leaks.
Let's fix this bug in pmic_glink_altmode_probe.
Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
---
The modifications made compared to the previous version are as follows:
1. Modified the patch title
2. Modified the commit message to make it easier to understand
patch's modifications.
drivers/soc/qcom/pmic_glink_altmode.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c
index df48fbea4b68..a7fc6570fa1e 100644
--- a/drivers/soc/qcom/pmic_glink_altmode.c
+++ b/drivers/soc/qcom/pmic_glink_altmode.c
@@ -395,7 +395,7 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
ret = fwnode_property_read_u32(fwnode, "reg", &port);
if (ret < 0) {
dev_err(dev, "missing reg property of %pOFn\n", fwnode);
- return ret;
+ goto err_node_put;
}
if (port >= ARRAY_SIZE(altmode->ports)) {
@@ -405,7 +405,8 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
if (altmode->ports[port].altmode) {
dev_err(dev, "multiple connector definition for port %u\n", port);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_node_put;
}
alt_port = &altmode->ports[port];
@@ -420,33 +421,37 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
ret = devm_drm_bridge_add(dev, &alt_port->bridge);
if (ret)
- return ret;
+ goto err_node_put;
alt_port->dp_alt.svid = USB_TYPEC_DP_SID;
alt_port->dp_alt.mode = USB_TYPEC_DP_MODE;
alt_port->dp_alt.active = 1;
alt_port->typec_mux = fwnode_typec_mux_get(fwnode);
- if (IS_ERR(alt_port->typec_mux))
- return dev_err_probe(dev, PTR_ERR(alt_port->typec_mux),
+ if (IS_ERR(alt_port->typec_mux)) {
+ ret = dev_err_probe(dev, PTR_ERR(alt_port->typec_mux),
"failed to acquire mode-switch for port: %d\n",
port);
+ goto err_node_put;
+ }
ret = devm_add_action_or_reset(dev, pmic_glink_altmode_put_mux,
alt_port->typec_mux);
if (ret)
- return ret;
+ goto err_node_put;
alt_port->typec_switch = fwnode_typec_switch_get(fwnode);
- if (IS_ERR(alt_port->typec_switch))
- return dev_err_probe(dev, PTR_ERR(alt_port->typec_switch),
+ if (IS_ERR(alt_port->typec_switch)) {
+ ret = dev_err_probe(dev, PTR_ERR(alt_port->typec_switch),
"failed to acquire orientation-switch for port: %d\n",
port);
+ goto err_node_put;
+ }
ret = devm_add_action_or_reset(dev, pmic_glink_altmode_put_switch,
alt_port->typec_switch);
if (ret)
- return ret;
+ goto err_node_put;
}
altmode->client = devm_pmic_glink_register_client(dev,
@@ -455,6 +460,10 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
pmic_glink_altmode_pdr_notify,
altmode);
return PTR_ERR_OR_ZERO(altmode->client);
+
+err_node_put:
+ fwnode_handle_put(fwnode);
+ return ret;
}
static const struct auxiliary_device_id pmic_glink_altmode_id_table[] = {
--
2.39.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] soc: qcom: pmic: Fix resource leaks in a device_for_each_child_node() loop
2023-06-12 13:34 [PATCH v3] soc: qcom: pmic: Fix resource leaks in a device_for_each_child_node() loop Lu Hongfei
@ 2023-09-19 23:07 ` Bjorn Andersson
2023-12-03 17:46 ` David Heidelberg
1 sibling, 0 replies; 4+ messages in thread
From: Bjorn Andersson @ 2023-09-19 23:07 UTC (permalink / raw)
To: Andy Gross, Konrad Dybcio, linux-arm-msm, linux-kernel, Lu Hongfei
Cc: opensource.kernel
On Mon, 12 Jun 2023 21:34:52 +0800, Lu Hongfei wrote:
> The device_for_each_child_node loop should call fwnode_handle_put()
> before return in some error cases, which could avoid resource leaks.
>
> Let's fix this bug in pmic_glink_altmode_probe.
>
>
Applied, thanks!
[1/1] soc: qcom: pmic: Fix resource leaks in a device_for_each_child_node() loop
commit: 5692aeea5bcb9331e956628c3bc8fc9afcc9765d
Best regards,
--
Bjorn Andersson <andersson@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] soc: qcom: pmic: Fix resource leaks in a device_for_each_child_node() loop
2023-06-12 13:34 [PATCH v3] soc: qcom: pmic: Fix resource leaks in a device_for_each_child_node() loop Lu Hongfei
2023-09-19 23:07 ` Bjorn Andersson
@ 2023-12-03 17:46 ` David Heidelberg
2023-12-03 18:12 ` Dmitry Baryshkov
1 sibling, 1 reply; 4+ messages in thread
From: David Heidelberg @ 2023-12-03 17:46 UTC (permalink / raw)
To: luhongfei
Cc: agross, andersson, konrad.dybcio, linux-arm-msm, linux-kernel,
opensource.kernel, stable
Heya!
I think this would be great candidate for backport, at least up to 6.6.
What do you think?
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] soc: qcom: pmic: Fix resource leaks in a device_for_each_child_node() loop
2023-12-03 17:46 ` David Heidelberg
@ 2023-12-03 18:12 ` Dmitry Baryshkov
0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Baryshkov @ 2023-12-03 18:12 UTC (permalink / raw)
To: David Heidelberg
Cc: luhongfei, agross, andersson, konrad.dybcio, linux-arm-msm,
linux-kernel, opensource.kernel, stable
On Sun, 3 Dec 2023 at 19:46, David Heidelberg <david@ixit.cz> wrote:
>
> Heya!
>
> I think this would be great candidate for backport, at least up to 6.6.
> What do you think?
Yes. Most likely it should have had:
Fixes: 080b4e24852b ("soc: qcom: pmic_glink: Introduce altmode support")
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-12-03 18:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 13:34 [PATCH v3] soc: qcom: pmic: Fix resource leaks in a device_for_each_child_node() loop Lu Hongfei
2023-09-19 23:07 ` Bjorn Andersson
2023-12-03 17:46 ` David Heidelberg
2023-12-03 18:12 ` Dmitry Baryshkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®