* [PATCH] clk: samsung: exynos5433: Fix potential NULL pointer dereference [not found] <CGME20191001130929eucas1p114d229f779680122c629396a4fc040c0@eucas1p1.samsung.com> @ 2019-10-01 13:09 ` Marek Szyprowski 2019-10-01 13:16 ` Krzysztof Kozlowski 2019-10-01 22:03 ` Chanwoo Choi 0 siblings, 2 replies; 4+ messages in thread From: Marek Szyprowski @ 2019-10-01 13:09 UTC (permalink / raw) To: linux-clk, linux-samsung-soc Cc: Marek Szyprowski, Sylwester Nawrocki, Chanwoo Choi, Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz 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; for (i = 0; i < data->nr_pclks; i++) { struct clk *clk = of_clk_get(dev->of_node, i); -- 2.17.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: samsung: exynos5433: Fix potential NULL pointer dereference 2019-10-01 13:09 ` [PATCH] clk: samsung: exynos5433: Fix potential NULL pointer dereference Marek Szyprowski @ 2019-10-01 13:16 ` Krzysztof Kozlowski 2019-10-01 13:22 ` Bartlomiej Zolnierkiewicz 2019-10-01 22:03 ` Chanwoo Choi 1 sibling, 1 reply; 4+ messages in thread From: Krzysztof Kozlowski @ 2019-10-01 13:16 UTC (permalink / raw) To: Marek Szyprowski Cc: linux-clk, linux-samsung-soc, Sylwester Nawrocki, Chanwoo Choi, Bartlomiej Zolnierkiewicz 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 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: samsung: exynos5433: Fix potential NULL pointer dereference 2019-10-01 13:16 ` Krzysztof Kozlowski @ 2019-10-01 13:22 ` Bartlomiej Zolnierkiewicz 0 siblings, 0 replies; 4+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2019-10-01 13:22 UTC (permalink / raw) To: Krzysztof Kozlowski, Marek Szyprowski Cc: linux-clk, linux-samsung-soc, Sylwester Nawrocki, Chanwoo Choi On 10/1/19 3:16 PM, Krzysztof Kozlowski wrote: > 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. Also we may want to fix the code to check samsung_clk_alloc_reg_dump() return value for NULL while we are at it.. > 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 Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: samsung: exynos5433: Fix potential NULL pointer dereference 2019-10-01 13:09 ` [PATCH] clk: samsung: exynos5433: Fix potential NULL pointer dereference Marek Szyprowski 2019-10-01 13:16 ` Krzysztof Kozlowski @ 2019-10-01 22:03 ` Chanwoo Choi 1 sibling, 0 replies; 4+ messages in thread From: Chanwoo Choi @ 2019-10-01 22:03 UTC (permalink / raw) To: Marek Szyprowski, linux-clk, linux-samsung-soc Cc: Sylwester Nawrocki, Krzysztof Kozlowski, Bartlomiej Zolnierkiewicz Hi, On 19. 10. 1. 오후 10:09, 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; > for (i = 0; i < data->nr_pclks; i++) { > struct clk *clk = of_clk_get(dev->of_node, i); > > I think it is needed when 'data->pclks' memory allocation failed. Acked-by: Chanwoo Choi <cw00.choi@samsung.com> -- Best Regards, Chanwoo Choi Samsung Electronics ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-01 21:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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
2019-10-01 13:22 ` Bartlomiej Zolnierkiewicz
2019-10-01 22:03 ` Chanwoo Choi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox