From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Colin King <colin.king@canonical.com>,
Zhang Rui <rui.zhang@intel.com>,
Eduardo Valentin <edubezval@gmail.com>,
linux-pm@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure
Date: Mon, 30 Jul 2018 16:14:53 +0200 [thread overview]
Message-ID: <cad2f4c3-77c1-c233-975d-ed72fd640163@linaro.org> (raw)
In-Reply-To: <20180730122716.6267-1-colin.king@canonical.com>
Hi Colin,
On 30/07/2018 14:27, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the drvdata allocation failure is being incorrectly checked by
> checking priv and not drvdata. Fix this and also free priv to fix a
> memory leak.
>
> Detected by Coverity Scan, CID#1472102 ("Logically dead code")
>
> Fixes: c9899c183921 ("thermal: armada: use the resource managed registration helper alternative")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/thermal/armada_thermal.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index 4164a5a4e480..b164fd9f21ac 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -611,8 +611,10 @@ static int armada_thermal_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
> - if (!priv)
> + if (!drvdata) {
> + devm_kfree(&pdev->dev, priv);
This is not necessary, resources will be free when the driver is
destroyed after the probe fails.
> return -ENOMEM;
> + }
>
> priv->dev = &pdev->dev;
> priv->data = (struct armada_thermal_data *)match->data;
Thanks for sending this fix. However, another fix was already submitted
for this.
-- Daniel
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
next prev parent reply other threads:[~2018-07-30 14:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 12:27 [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure Colin King
2018-07-30 14:14 ` Daniel Lezcano [this message]
2018-08-20 18:52 ` Eduardo Valentin
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=cad2f4c3-77c1-c233-975d-ed72fd640163@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=colin.king@canonical.com \
--cc=edubezval@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rui.zhang@intel.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;
as well as URLs for NNTP newsgroup(s).