PNP: fix name memory leak in pnp_alloc_dev()
authorYang Yingliang <yangyingliang@huawei.com>
Fri, 11 Nov 2022 01:23:58 +0000 (09:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jan 2023 11:07:14 +0000 (12:07 +0100)
commitea77b4b761cd75e5456f677311babfa0418f289a
treea358e4d02030ed1f4ddfa329d5998a90f104cec8
parentc5b088a6bbbbf0ef8199a41bf0d82638429ed0fd
PNP: fix name memory leak in pnp_alloc_dev()

[ Upstream commit 110d7b0325c55ff3620073ba4201845f59e22ebf ]

After commit 1fa5ae857bb1 ("driver core: get rid of struct device's
bus_id string array"), the name of device is allocated dynamically,
move dev_set_name() after pnp_add_id() to avoid memory leak.

Fixes: 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pnp/core.c