Skip to content
Commit e6d773f9 authored by Yang Yingliang's avatar Yang Yingliang Committed by Martin K. Petersen
Browse files

scsi: scsi_debug: Fix possible name leak in sdebug_add_host_helper()



Afer commit 1fa5ae85 ("driver core: get rid of struct device's bus_id
string array"), the name of device is allocated dynamically, it needs be
freed when device_register() returns error.

As comment of device_register() says, one should use put_device() to give
up the reference in the error path. Fix this by calling put_device(), then
the name can be freed in kobject_cleanup(), and sdbg_host is freed in
sdebug_release_adapter().

When the device release is not set, it means the device is not initialized.
We can not call put_device() in this case. Use kfree() to free memory.

Fixes: 1fa5ae85 ("driver core: get rid of struct device's bus_id string array")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221112131010.3757845-1-yangyingliang@huawei.com


Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 47b6a122
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