Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH v2] scsi: hpsa: Fix memory leak in hpsa_undo_allocations_after_kdump_soft_reset()
@ 2025-12-31 14:59 Zilin Guan
  2025-12-31 16:25 ` Markus Elfring
  0 siblings, 1 reply; 4+ messages in thread
From: Zilin Guan @ 2025-12-31 14:59 UTC (permalink / raw)
  To: don.brace
  Cc: James.Bottomley, martin.petersen, storagedev, linux-scsi,
	linux-kernel, Markus.Elfring, Zilin Guan, Jianhao Xu

The h->reply_map is allocated in hpda_alloc_ctlr_info() via kcalloc().
If the controller reset fails during initialization in hpsa_init_one(),
hpsa_undo_allocations_after_kdump_soft_reset() is called to clean up
resources. However, this function frees the controller structure h but
fails to free h->reply_map, leading to a memory leak.

Fix this by freeing h->reply_map before freeing h in the cleanup function.

Fixes: 8b834bff1b73 ("scsi: hpsa: fix selection of reply queue")
Suggested-by: Markus Elfring <Markus.Elfring@web.de>
Co-developed-by: Jianhao Xu <jianhao.xu@seu.edu.cn>
Signed-off-by: Jianhao Xu <jianhao.xu@seu.edu.cn>
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
---
Changes in v2:
- Remove redundant NULL assignment for h->reply_map.

 drivers/scsi/hpsa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3654b12c5d5a..ce69cd381e9f 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -8212,6 +8212,7 @@ static void hpsa_undo_allocations_after_kdump_soft_reset(struct ctlr_info *h)
 		h->monitor_ctlr_wq = NULL;
 	}
 
+	kfree(h->reply_map);		/* init_one 1 */
 	kfree(h);				/* init_one 1 */
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-03 13:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-31 14:59 [PATCH v2] scsi: hpsa: Fix memory leak in hpsa_undo_allocations_after_kdump_soft_reset() Zilin Guan
2025-12-31 16:25 ` Markus Elfring
2026-01-03 12:39   ` Zilin Guan
2026-01-03 13:34     ` Zilin Guan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox