Zhu Wang 06c5340858 scsi: core: Fix possible memory leak if device_add() fails
commit 04b5b5cb0136ce970333a9c6cec7e46adba1ea3a upstream.

If device_add() returns error, the name allocated by dev_set_name() needs
be freed. As the comment of device_add() says, put_device() should be used
to decrease the reference count in the error path. So fix this by calling
put_device(), then the name can be freed in kobject_cleanp().

Fixes: ee959b00c335 ("SCSI: convert struct class_device to struct device")
Signed-off-by: Zhu Wang <wangzhu9@huawei.com>
Link: https://lore.kernel.org/r/20230803020230.226903-1-wangzhu9@huawei.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-16 18:13:01 +02:00
..
2021-07-20 16:16:08 +02:00
2021-07-20 16:16:08 +02:00
2018-08-21 23:54:17 -04:00
2017-12-04 20:32:53 -05:00
2018-06-19 22:02:25 -04:00
2018-06-19 22:02:25 -04:00
2018-06-19 22:02:25 -04:00
2018-06-19 22:02:25 -04:00
2019-12-01 09:16:26 +01:00
2021-05-22 10:59:33 +02:00
2018-08-15 22:06:26 -07:00
2018-06-12 16:19:22 -07:00
2017-11-14 16:23:44 -08:00
2018-08-15 22:06:26 -07:00
2018-06-10 13:01:12 -07:00
2018-06-19 22:02:25 -04:00
2018-08-15 22:06:26 -07:00
2021-05-22 10:59:34 +02:00
2022-01-27 09:04:30 +01:00
2022-01-27 09:04:30 +01:00
2023-06-09 10:24:02 +02:00
2021-05-22 10:59:34 +02:00
2018-05-01 23:30:12 -04:00