Skip to content

Commit

Permalink
pinctrl: pinconf-generic: Use kmemdup instead of kmalloc + memcpy
Browse files Browse the repository at this point in the history
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci

Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Benoit Taine authored and Linus Walleij committed May 27, 2014
1 parent 49cfabc commit db388df
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/pinctrl/pinconf-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit db388df

Please sign in to comment.