diff options
author | Zhu Wang <wangzhu9@huawei.com> | 2023-08-19 08:39:41 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-08-30 16:23:18 +0200 |
commit | 5d02f4320a9502201bf9c174747a0dc4deb4d205 (patch) | |
tree | 0d9b12c2d542ac5b690e6c3d0994bb91924d7e01 /lib/string_helpers.c | |
parent | d643d3f322e85487bb0a1670b9f306032f967037 (diff) |
scsi: snic: Fix double free in snic_tgt_create()
commit 1bd3a76880b2bce017987cf53780b372cf59528e upstream.
Commit 41320b18a0e0 ("scsi: snic: Fix possible memory leak if device_add()
fails") fixed the memory leak caused by dev_set_name() when device_add()
failed. However, it did not consider that 'tgt' has already been released
when put_device(&tgt->dev) is called. Remove kfree(tgt) in the error path
to avoid double free of 'tgt' and move put_device(&tgt->dev) after the
removed kfree(tgt) to avoid a use-after-free.
Fixes: 41320b18a0e0 ("scsi: snic: Fix possible memory leak if device_add() fails")
Signed-off-by: Zhu Wang <wangzhu9@huawei.com>
Link: https://lore.kernel.org/r/20230819083941.164365-1-wangzhu9@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/string_helpers.c')
0 files changed, 0 insertions, 0 deletions