| From f0d033d59d6b9967a923119c882132e114f4e625 Mon Sep 17 00:00:00 2001 |
| From: Gen Zhang <blackgod016574@gmail.com> |
| Date: Tue, 28 May 2019 10:18:51 +0800 |
| Subject: [PATCH] clk-sunxi: fix a missing-check bug in sunxi_divs_clk_setup() |
| |
| commit fcdf445ff42f036d22178b49cf64e92d527c1330 upstream. |
| |
| 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 <blackgod016574@gmail.com> |
| Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c |
| index 623fda5e911f..d3a43381a792 100644 |
| --- a/drivers/clk/sunxi/clk-sunxi.c |
| +++ b/drivers/clk/sunxi/clk-sunxi.c |
| @@ -980,6 +980,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; |
| -- |
| 2.7.4 |
| |