From: Krzysztof Kozlowski <krzk@kernel.org>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-clk@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
Sylwester Nawrocki <snawrocki@kernel.org>,
Chanwoo Choi <cw00.choi@samsung.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [PATCH] clk: samsung: exynos5433: Fix potential NULL pointer dereference
Date: Tue, 1 Oct 2019 15:16:41 +0200 [thread overview]
Message-ID: <20191001131641.GA30129@pi3> (raw)
In-Reply-To: <20191001130921.24571-1-m.szyprowski@samsung.com>
On Tue, Oct 01, 2019 at 03:09:21PM +0200, Marek Szyprowski wrote:
> devm_kcalloc might fail, so avoid accessing the allocated object in such
> case.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> drivers/clk/samsung/clk-exynos5433.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c
> index 7824c2ba3d8e..6afbcd0ae96f 100644
> --- a/drivers/clk/samsung/clk-exynos5433.c
> +++ b/drivers/clk/samsung/clk-exynos5433.c
> @@ -5592,7 +5592,8 @@ static int __init exynos5433_cmu_probe(struct platform_device *pdev)
> if (data->nr_pclks > 0) {
> data->pclks = devm_kcalloc(dev, sizeof(struct clk *),
> data->nr_pclks, GFP_KERNEL);
> -
> + if (!data->pclks)
> + return -ENOMEM;
You leak the memory from the samsung_clk_alloc_reg_dump() call.
The error path few lines later (from of_clk_get()) leaks it as well.
Best regards,
Krzysztof
> for (i = 0; i < data->nr_pclks; i++) {
> struct clk *clk = of_clk_get(dev->of_node, i);
>
> --
> 2.17.1
>
next prev parent reply other threads:[~2019-10-01 13:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20191001130929eucas1p114d229f779680122c629396a4fc040c0@eucas1p1.samsung.com>
2019-10-01 13:09 ` [PATCH] clk: samsung: exynos5433: Fix potential NULL pointer dereference Marek Szyprowski
2019-10-01 13:16 ` Krzysztof Kozlowski [this message]
2019-10-01 13:22 ` Bartlomiej Zolnierkiewicz
2019-10-01 22:03 ` Chanwoo Choi
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=20191001131641.GA30129@pi3 \
--to=krzk@kernel.org \
--cc=b.zolnierkie@samsung.com \
--cc=cw00.choi@samsung.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=snawrocki@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.