scsi: hpsa: Fix possible memory leak in hpsa_init_one()
Subsystems (2)
PATCH 1/1 scsi: hpsa: Fix possible memory leak in hpsa_init_one()
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.
--- drivers/scsi/hpsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hpsa.c +1 -1
@@ -8925,7 +8925,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)destroy_workqueue (h->monitor_ctlr_wq); h->monitor_ctlr_wq =NULL ; } -kfree (h); +hpda_free_ctlr_info (h);return rc; }
Signature · 1 line
2.17.1
Quoted 17 lines · Yuan Can
The
hpda_alloc_ctlr_info()allocates h and its fieldreply_map, however inhpsa_init_one(), ifalloc_percpu()failed, thehpsa_init_one()jumps to clean1 directly, which frees h and leaks theh->reply_map.
Fix by callinghpda_free_ctlr_info()to releaseh->replay_mapand h instead free h directly.Fixes 8b834bff1b73 ("scsi: hpsa: fix selection of reply queue")Signed-off-by Yuan Can <[email protected]>--- drivers/scsi/hpsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/hpsa.c +0
-0
drivers/scsi/hpsa.c static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · line 8928
Quoted 5 lines
drivers/scsi/hpsa.c +1
-1@@ -8925,7 +8925,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)destroy_workqueue (h->monitor_ctlr_wq); h->monitor_ctlr_wq =NULL ; } -kfree (h); +hpda_free_ctlr_info (h);
Thanks,
Ming
Martin K. Petersen
AppliedYuan,
Quoted 5 lines
The
hpda_alloc_ctlr_info()allocates h and its fieldreply_map, however inhpsa_init_one(), ifalloc_percpu()failed, thehpsa_init_one()jumps to clean1 directly, which frees h and leaks theh->reply_map. Fix by callinghpda_free_ctlr_info()to releaseh->replay_mapand h instead free h directly.
Applied to 6.2/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 8 lines · Yuan Can
The
hpda_alloc_ctlr_info()allocates h and its fieldreply_map, however inhpsa_init_one(), ifalloc_percpu()failed, thehpsa_init_one()jumps to clean1 directly, which frees h and leaks theh->reply_map.
Fix by callinghpda_free_ctlr_info()to releaseh->replay_mapand h instead free h directly.[...]
Applied to 6.2/scsi-queue, thanks!
[1/1] scsi: hpsa: Fix possible memory leak in hpsa_init_one()
https://git.kernel.org/mkp/scsi/c/9c9ff300e0de
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering