drivers: base: transport_class: fix possible memory leak
[ Upstream commita863678038] Current some drivers(like iscsi) call transport_register_device() failed, they don't call transport_destroy_device() to release the memory allocated in transport_setup_device(), because they don't know what was done, it should be internal thing to release the resource in register function. So fix this leak by calling destroy function inside register function. Fixes:1da177e4c3("Linux-2.6.12-rc2") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://lore.kernel.org/r/20221110102307.3492557-1-yangyingliang@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
8fe72b8f59
commit
e77745640f
1 changed files with 7 additions and 1 deletions
|
|
@ -70,8 +70,14 @@ void transport_destroy_device(struct device *);
|
|||
static inline int
|
||||
transport_register_device(struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
transport_setup_device(dev);
|
||||
return transport_add_device(dev);
|
||||
ret = transport_add_device(dev);
|
||||
if (ret)
|
||||
transport_destroy_device(dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue