* [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
* Re: [PATCH v2] scsi: hpsa: Fix memory leak in hpsa_undo_allocations_after_kdump_soft_reset()
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
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2025-12-31 16:25 UTC (permalink / raw)
To: Jianhao Xu, Zilin Guan, linux-scsi, storagedev, Don Brace
Cc: LKML, James Bottomley, Martin K. Petersen
…
> +++ 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 */
> }
I wonder about the alignment and relevance for these code comments.
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: hpsa: Fix memory leak in hpsa_undo_allocations_after_kdump_soft_reset()
2025-12-31 16:25 ` Markus Elfring
@ 2026-01-03 12:39 ` Zilin Guan
2026-01-03 13:34 ` Zilin Guan
0 siblings, 1 reply; 4+ messages in thread
From: Zilin Guan @ 2026-01-03 12:39 UTC (permalink / raw)
To: markus.elfring
Cc: James.Bottomley, don.brace, jianhao.xu, linux-kernel, linux-scsi,
martin.petersen, storagedev, zilin
On Wed, Dec 31, 2025 at 05:25:23PM +0100, Markus Elfring wrote:
> …
> > +++ 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 */
> > }
>
> I wonder about the alignment and relevance for these code comments.
>
> Regards,
> Markus
Hi Markus,
Thank you for your review.
Regarding the alignment, it was an oversight caused by the inconsistency
between my editor configuration and the Linux kernel's style. I will
correct this in v3.
As for the code comment, it indicates that the memory being freed here
was allocated during the first stage of initialization in
hpsa_init_one(). I included it to maintain consistency with the existing
kfree(h) line immediately following it.
Best regards,
Zilin Guan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: hpsa: Fix memory leak in hpsa_undo_allocations_after_kdump_soft_reset()
2026-01-03 12:39 ` Zilin Guan
@ 2026-01-03 13:34 ` Zilin Guan
0 siblings, 0 replies; 4+ messages in thread
From: Zilin Guan @ 2026-01-03 13:34 UTC (permalink / raw)
To: zilin
Cc: James.Bottomley, don.brace, jianhao.xu, linux-kernel, linux-scsi,
markus.elfring, martin.petersen, storagedev
On Sat, Jan 03, 2026 at 12:39:10PM +0000, Zilin Guan wrote:
> Hi Markus,
>
> Thank you for your review.
>
> Regarding the alignment, it was an oversight caused by the inconsistency
> between my editor configuration and the Linux kernel's style. I will
> correct this in v3.
Apologies, please disregard my previous reply.
I realized that the perceived misalignment is actually a tab rendering
artifact. I have verified that the indentation in v2 is correct and
aligns perfectly with the surrounding code when applied.
Therefore, v2 is correct as-is and a v3 is not necessary.
Best regards,
Zilin Guan
^ permalink raw reply [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