scsi: hpsa: Fix possible memory leak in hpsa_init_one()

[ Upstream commit 9c9ff300e0 ]

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: 8b834bff1b ("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>
This commit is contained in:
Yuan Can 2022-11-22 01:57:51 +00:00 committed by Greg Kroah-Hartman
parent 4fdd11312e
commit fc998d0a7d
1 changed files with 1 additions and 1 deletions

View File

@ -8929,7 +8929,7 @@ clean1: /* wq/aer/h */
destroy_workqueue(h->monitor_ctlr_wq);
h->monitor_ctlr_wq = NULL;
}
kfree(h);
hpda_free_ctlr_info(h);
return rc;
}