of/device: Fix platform_device.name point to an freed memory after
authorMeiyou Chen <cmy@rock-chips.com>
Fri, 11 Sep 2015 02:30:54 +0000 (10:30 +0800)
committerMeiyou Chen <cmy@rock-chips.com>
Fri, 11 Sep 2015 02:42:53 +0000 (10:42 +0800)
commita51927d3ac36b6f5ec741040d7b694e73f0fbeaf
tree9b47749a9edcd50ea455b39b0c35bcb740b5734b
parent8be554a50237051e45ef92ba8b873268f659a84b
of/device: Fix platform_device.name point to an freed memory after
dev_set_name()

When we use of_device_add() to create platform_device and add it to device
hierarchy, the platform_device.name and device's name will point to the same
memory.

Later we use dev_set_name() to change the device's name, it will alloc new
memory to store name and free old device's name. After it, the
platform_device.name will point to an freed memory, access platform_device.name
 maybe lead to unpredictable exceptions.

So, we alloc new memory for platform_device.name in of_device_add()

Change-Id: I59bf0941ee4e094053971d41d386206e47fddcaa
Signed-off-by: Meiyou Chen <cmy@rock-chips.com>
drivers/of/device.c