From: Mukesh Ojha <quic_mojha@quicinc.com>
To: Lu Hongfei <luhongfei@vivo.com>, Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
"open list:ARM/QUALCOMM SUPPORT" <linux-arm-msm@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Cc: <opensource.kernel@vivo.com>
Subject: Re: [PATCH] soc: qcom: pmic: Fix resource leaks in device_for_each_child_node() loops
Date: Wed, 31 May 2023 13:48:02 +0530 [thread overview]
Message-ID: <7c1a43ee-d0ca-3deb-24e5-0423a188b459@quicinc.com> (raw)
In-Reply-To: <20230531075513.55182-1-luhongfei@vivo.com>
On 5/31/2023 1:25 PM, Lu Hongfei wrote:
> The device_for_each_child_node loop in pmic_glink_altmode_probe should have
> fwnode_handle_put() before return which could avoid resource leaks.
> This patch could fix this bug.
>
> Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
Use Fixes: tag
Otherwise LGTM.
Reviewed-by: Mukesh Ojha <quic_mojha@quicinc.com>
-- Mukesh
> ---
> 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
> --- 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[] = {
next prev parent reply other threads:[~2023-05-31 8:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 7:55 Lu Hongfei
2023-05-31 8:18 ` Mukesh Ojha [this message]
[not found] <TYZPR06MB66976D6A4FC1674574531D45CE489@TYZPR06MB6697.apcprd06.prod.outlook.com>
2023-05-31 12:19 ` Konrad Dybcio
-- strict thread matches above, loose matches on Subject: below --
2023-05-31 8:54 Lu Hongfei
2023-05-31 9:03 ` Konrad Dybcio
2023-05-31 8:39 Lu Hongfei
2023-05-31 6:44 Lu Hongfei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7c1a43ee-d0ca-3deb-24e5-0423a188b459@quicinc.com \
--to=quic_mojha@quicinc.com \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luhongfei@vivo.com \
--cc=opensource.kernel@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®