mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] hpsa: fix a memory leak in hpsa_find_cfgtables()
@ 2026-01-08  7:32 Haoxiang Li
  2026-01-10  6:55 ` Markus Elfring
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-01-08  7:32 UTC (permalink / raw)
  To: don.brace, James.Bottomley, martin.petersen, jbottomley, scameron
  Cc: storagedev, linux-scsi, linux-kernel, Haoxiang Li, stable

If write_driver_ver_to_cfgtable() fails, add iounmap() to
release the memory allocated by remap_pci_mem().

Found by manual static code review.

Fixes: 580ada3c1e2f ("[SCSI] hpsa: do a better job of detecting controller reset failure")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
Changes in v2:
- replace iounmap with unified release method. Thanks, Greg!
---
 drivers/scsi/hpsa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3654b12c5d5a..e38d4a7488f8 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -7646,8 +7646,10 @@ static int hpsa_find_cfgtables(struct ctlr_info *h)
 		return -ENOMEM;
 	}
 	rc = write_driver_ver_to_cfgtable(h->cfgtable);
-	if (rc)
+	if (rc) {
+		hpsa_free_cfgtables(h);
 		return rc;
+	}
 	/* Find performant mode table. */
 	trans_offset = readl(&h->cfgtable->TransMethodOffset);
 	h->transtable = remap_pci_mem(pci_resource_start(h->pdev,
-- 
2.25.1


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

* Re: [PATCH v2] hpsa: fix a memory leak in hpsa_find_cfgtables()
  2026-01-08  7:32 [PATCH v2] hpsa: fix a memory leak in hpsa_find_cfgtables() Haoxiang Li
@ 2026-01-10  6:55 ` Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2026-01-10  6:55 UTC (permalink / raw)
  To: Haoxiang Li, linux-scsi, storagedev, Don Brace, James Bottomley,
	Martin K. Petersen
  Cc: stable, LKML, kernel-janitors

> If write_driver_ver_to_cfgtable() fails, add iounmap() to
> release the memory allocated by remap_pci_mem().

How do you think about to avoid a bit of duplicate source code here?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.19-rc4#n526

See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.19-rc4#n659


> Found by manual static code review.

Can such information indicate a contradiction?

Regards,
Markus

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

end of thread, other threads:[~2026-01-10  6:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-08  7:32 [PATCH v2] hpsa: fix a memory leak in hpsa_find_cfgtables() Haoxiang Li
2026-01-10  6:55 ` Markus Elfring

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

all inboxes | Powered by JetHome®