]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
powerpc/pseries: replace kmalloc + strlcpy
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 1 Oct 2015 09:46:08 +0000 (12:46 +0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 5 Oct 2015 10:11:26 +0000 (21:11 +1100)
The helper kstrndup() will do the same in one line.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/pseries/of_helpers.c

index 2f363e3286d17bba20c76bb72446bc52a02923e5..8c6b05ae1a1d09ed7bc02934ef6933e7376215e8 100644 (file)
@@ -24,10 +24,9 @@ struct device_node *pseries_of_derive_parent(const char *path)
                return ERR_PTR(-EINVAL);
 
        if (strrchr(path, '/') != path) {
-               parent_path = kmalloc(parent_path_len, GFP_KERNEL);
+               parent_path = kstrndup(path, parent_path_len, GFP_KERNEL);
                if (!parent_path)
                        return ERR_PTR(-ENOMEM);
-               strlcpy(parent_path, path, parent_path_len);
        }
        parent = of_find_node_by_path(parent_path);
        if (strcmp(parent_path, "/"))