2019-05-28 02:22:06

by Gen Zhang

[permalink] [raw]
Subject: [PATCH] clk-sunxi: fix a missing-check bug in sunxi_divs_clk_setup()

In sunxi_divs_clk_setup(), 'derived_name' is allocated by kstrndup().
It returns NULL when fails. 'derived_name' should be checked.

Signed-off-by: Gen Zhang <[email protected]>
---
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index f5b1c00..830bfb7 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -989,6 +989,8 @@ static struct clk ** __init sunxi_divs_clk_setup(struct device_node *node,
if (endp) {
derived_name = kstrndup(clk_name, endp - clk_name,
GFP_KERNEL);
+ if (!derived_name)
+ return NULL;
factors.name = derived_name;
} else {
factors.name = clk_name;
---


2019-05-29 08:07:28

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH] clk-sunxi: fix a missing-check bug in sunxi_divs_clk_setup()

On Tue, May 28, 2019 at 10:18:51AM +0800, Gen Zhang wrote:
> In sunxi_divs_clk_setup(), 'derived_name' is allocated by kstrndup().
> It returns NULL when fails. 'derived_name' should be checked.
>
> Signed-off-by: Gen Zhang <[email protected]>

Applied, thanks
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


Attachments:
(No filename) (373.00 B)
signature.asc (235.00 B)
Download all attachments