Skip to content
Commit 99e12410 authored by Yang Yingliang's avatar Yang Yingliang Committed by Dominik Brodowski
Browse files

pcmcia: ds: fix possible name leak in error path in pcmcia_device_add()

Afer commit 1fa5ae85 ("driver core: get rid of struct device's
bus_id string array"), the name of device is allocated dynamically.
Therefore, it needs to be freed, which is done by the driver core for
us once all references to the device are gone. Therefore, move the
dev_set_name() call immediately before the call device_register(), which
either succeeds (then the freeing will be done upon subsequent remvoal),
or puts the reference in the error call. Also, it is not unusual that the
return value of dev_set_name is not checked.

Fixes: 1fa5ae85

 ("driver core: get rid of struct device's bus_id string array")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
[linux@dominikbrodowski.net: simplification, commit message modified]
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 402ab979
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment