scsi: hpsa: Fix possible memory leak in hpsa_init_one()
authorYuan Can <yuancan@huawei.com>
Tue, 22 Nov 2022 01:57:51 +0000 (01:57 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:34 +0000 (13:32 +0100)
commit0aa7be66168b1e84b2581ffff3ccb54a6c804a1e
treeb185951b9e57cf84ab07aabe4a3cc51b925ab458
parent21d8b6bd3730fc6af7ff0eb3c65a8364da310f66
scsi: hpsa: Fix possible memory leak in hpsa_init_one()

[ Upstream commit 9c9ff300e0de07475796495d86f449340d454a0c ]

The hpda_alloc_ctlr_info() allocates h and its field reply_map. However, in
hpsa_init_one(), if alloc_percpu() failed, the hpsa_init_one() jumps to
clean1 directly, which frees h and leaks the h->reply_map.

Fix by calling hpda_free_ctlr_info() to release h->replay_map and h instead
free h directly.

Fixes: 8b834bff1b73 ("scsi: hpsa: fix selection of reply queue")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Link: https://lore.kernel.org/r/20221122015751.87284-1-yuancan@huawei.com
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/hpsa.c