of/device: Fix platform_device.name point to an freed memory after
[firefly-linux-kernel-4.4.55.git] / drivers / of / device.c
index 4f942b56fab95d117eb7c2aff94f3e8528361032..3f447474414ebb1f7af928a85990d572f8b3ffbb 100644 (file)
@@ -54,7 +54,11 @@ int of_device_add(struct platform_device *ofdev)
 
        /* name and id have to be set so that the platform bus doesn't get
         * confused on matching */
+#ifdef CONFIG_ARCH_ROCKCHIP
+       ofdev->name = kasprintf(GFP_KERNEL, "%s", dev_name(&ofdev->dev));
+#else
        ofdev->name = dev_name(&ofdev->dev);
+#endif
        ofdev->id = -1;
 
        /* device_add will assume that this device is on the same node as