summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/sunxi
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2014-05-30 14:20:52 +0400
committerLinus Walleij <linus.walleij@linaro.org>2014-06-19 11:34:56 +0400
commitbd07894e217b174361711320be50c8308456096d (patch)
treec641beb3279edfca46b9d9619ece020449d47914 /drivers/pinctrl/sunxi
parent7171511eaec5bf23fb06078f59784a3a0626b38f (diff)
downloadlinux-bd07894e217b174361711320be50c8308456096d.tar.xz
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: Sachin Kamat <sachin.kamat@linaro.org> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/sunxi')
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sunxi.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index f1ca75e6d7b1..5f38c7f67834 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -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;