Commit db388dfb authored by Benoit Taine's avatar Benoit Taine Committed by Linus Walleij

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: default avatarBenoit Taine <benoit.taine@lip6.fr>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 49cfabc2
...@@ -228,13 +228,12 @@ int pinconf_generic_parse_dt_config(struct device_node *np, ...@@ -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 * Now limit the number of configs to the real number of
* found properties. * found properties.
*/ */
*configs = kzalloc(ncfg * sizeof(unsigned long), GFP_KERNEL); *configs = kmemdup(cfg, ncfg * sizeof(unsigned long), GFP_KERNEL);
if (!*configs) { if (!*configs) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
memcpy(*configs, cfg, ncfg * sizeof(unsigned long));
*nconfigs = ncfg; *nconfigs = ncfg;
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment