From db388dfb90368638ad238c27b045b6c9bf1f6c17 Mon Sep 17 00:00:00 2001 From: Benoit Taine Date: Mon, 26 May 2014 17:21:27 +0200 Subject: [PATCH] pinctrl: pinconf-generic: Use kmemdup instead of kmalloc + memcpy This issue was reported by coccicheck using the semantic patch at scripts/coccinelle/api/memdup.cocci Signed-off-by: Benoit Taine Signed-off-by: Linus Walleij --- drivers/pinctrl/pinconf-generic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c index 3d9a999fb699..2457ca961f1c 100644 --- a/drivers/pinctrl/pinconf-generic.c +++ b/drivers/pinctrl/pinconf-generic.c @@ -228,13 +228,12 @@ int pinconf_generic_parse_dt_config(struct device_node *np, * Now limit the number of configs to the real number of * found properties. */ - *configs = kzalloc(ncfg * sizeof(unsigned long), GFP_KERNEL); + *configs = kmemdup(cfg, ncfg * sizeof(unsigned long), GFP_KERNEL); if (!*configs) { ret = -ENOMEM; goto out; } - memcpy(*configs, cfg, ncfg * sizeof(unsigned long)); *nconfigs = ncfg; out: