Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd07894e authored by Sachin Kamat's avatar Sachin Kamat Committed by Linus Walleij
Browse files

pinctrl: sunxi: Fix potential null pointer dereference



kzalloc can fail. Add a null check to avoid null pointer
dereference error while accessing the pointer later.

Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Acked-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 7171511e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -211,6 +211,10 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
			configlen++;

		pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL);
		if (!pinconfig) {
			kfree(*map);
			return -ENOMEM;
		}

		if (!of_property_read_u32(node, "allwinner,drive", &val)) {
			u16 strength = (val + 1) * 10;