Gaosheng Cui 6866154c23 scsi: snic: Fix possible UAF in snic_tgt_create()
[ Upstream commit e118df492320176af94deec000ae034cc92be754 ]

Smatch reports a warning as follows:

drivers/scsi/snic/snic_disc.c:307 snic_tgt_create() warn:
  '&tgt->list' not removed from list

If device_add() fails in snic_tgt_create(), tgt will be freed, but
tgt->list will not be removed from snic->disc.tgt_list, then list traversal
may cause UAF.

Remove from snic->disc.tgt_list before free().

Fixes: c8806b6c9e82 ("snic: driver for Cisco SCSI HBA")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Link: https://lore.kernel.org/r/20221117035100.2944812-1-cuigaosheng1@huawei.com
Acked-by: Narsimhulu Musini <nmusini@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-01-18 11:41:20 +01:00
..
2021-07-20 16:10:43 +02:00
2021-07-20 16:10:43 +02:00
2019-03-02 11:39:54 -08:00
2019-07-11 15:17:41 -07:00
2019-01-08 21:58:35 -05:00
2019-01-08 21:58:35 -05:00
2019-07-11 15:14:01 -07:00
2019-06-18 19:46:18 -04:00
2019-07-11 15:17:41 -07:00
2023-01-18 11:41:20 +01:00
2018-12-18 23:19:21 -05:00
2021-05-14 09:44:25 +02:00
2019-07-11 15:14:01 -07:00
2022-02-16 12:52:49 +01:00
2019-08-16 11:33:56 -07:00
2019-08-16 11:33:56 -07:00
2019-07-11 15:14:01 -07:00
2019-11-05 23:17:53 -05:00
2019-08-04 21:41:29 -06:00
2018-12-18 23:19:21 -05:00
2021-05-14 09:44:25 +02:00
2022-01-27 09:19:48 +01:00
2022-01-27 09:19:48 +01:00
2021-05-14 09:44:25 +02:00
2019-07-11 15:14:01 -07:00