Message ID | 20161118113557.GA3281@mwanda |
---|---|
State | New |
Headers | show |
On Fri, Nov 18, 2016 at 02:35:57PM +0300, Dan Carpenter wrote: > Smatch complains that we dereference "map" before testing it for NULL > which is true. We should be testing "*map" instead. Also on the error > path, we should free *map and set it to NULL. > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Thanks! Maxime
On Fri, Nov 18, 2016 at 12:35 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote: > Smatch complains that we dereference "map" before testing it for NULL > which is true. We should be testing "*map" instead. Also on the error > path, we should free *map and set it to NULL. > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Patch applied with Maxime's ACK. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 2339d47..5b0acba 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -398,13 +398,14 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, * map array */ *map = krealloc(*map, i * sizeof(struct pinctrl_map), GFP_KERNEL); - if (!map) + if (!*map) return -ENOMEM; return 0; err_free_map: - kfree(map); + kfree(*map); + *map = NULL; return ret; }
Smatch complains that we dereference "map" before testing it for NULL which is true. We should be testing "*map" instead. Also on the error path, we should free *map and set it to NULL. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html