pinctrl: pinconf-generic: Use kmemdup instead of kmalloc + memcpy
authorBenoit Taine <benoit.taine@lip6.fr>
Mon, 26 May 2014 15:21:27 +0000 (17:21 +0200)
committerSimon Horman <horms@verge.net.au>
Fri, 5 Dec 2014 00:22:44 +0000 (09:22 +0900)
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>
(cherry picked from commit db388dfb90368638ad238c27b045b6c9bf1f6c17)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
drivers/pinctrl/pinconf-generic.c

index 3d9a999..2457ca9 100644 (file)
@@ -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: