A new_map is allocated in at91_dt_node_to_map but it is not freed in at91_dt_free_map, causing a memory leak. Fix it by using kcalloc to allocate new_map and free it in at91_dt_free_map Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@xxxxxxx> --- drivers/pinctrl/pinctrl-at91.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index d91a010e65f5..32ab983a77fe 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -291,8 +291,7 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev, } map_num += grp->npins; - new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map), - GFP_KERNEL); + new_map = kcalloc(map_num, sizeof(*new_map), GFP_KERNEL); if (!new_map) return -ENOMEM; @@ -302,7 +301,7 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev, /* create mux map */ parent = of_get_parent(np); if (!parent) { - devm_kfree(pctldev->dev, new_map); + kfree(new_map); return -EINVAL; } new_map[0].type = PIN_MAP_TYPE_MUX_GROUP; @@ -329,6 +328,7 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev, static void at91_dt_free_map(struct pinctrl_dev *pctldev, struct pinctrl_map *map, unsigned num_maps) { + kfree(map); } static const struct pinctrl_ops at91_pctrl_ops = { -- 2.17.1