Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: megaraid_sas: fix hb_host_mem leak on init failure
@ 2026-09-04  9:27 Li Youhong
  2026-09-04  9:47 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Li Youhong @ 2026-09-04  9:27 UTC (permalink / raw)
  To: kashyap.desai, sumit.saxena, shivasharan.srikanteshwara,
	chandrakanth.patil
  Cc: James.Bottomley, mkp, megaraidlinux.pdl, linux-scsi, Li Youhong

From: Li Youhong <liyouhong@kylinos.cn>

hb_host_mem is allocated in megasas_sriov_start_heartbeat() but only
freed in megasas_detach_one(). megasas_init_fw() and megasas_resume()
failure paths clean up through megasas_free_ctrl_dma_buffers(), which
did not free this buffer.

Move the free from megasas_detach_one() into
megasas_free_ctrl_dma_buffers().

Fixes: 229fe47cd046 ("[SCSI] megaraid_sas: Add Dell PowerEdge VRTX SR-IOV VF support")
Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
---
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index f0152b043e18..b1fbe06d3c67 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -7404,6 +7404,12 @@ void megasas_free_ctrl_dma_buffers(struct megasas_instance *instance)
 				  instance->host_device_list_buf,
 				  instance->host_device_list_buf_h);
 
+	if (instance->hb_host_mem)
+		dma_free_coherent(&pdev->dev,
+				  sizeof(struct MR_CTRL_HB_HOST_MEM),
+				  instance->hb_host_mem,
+				  instance->hb_host_mem_h);
+
 }
 
 /*
@@ -8081,11 +8087,6 @@ static void megasas_detach_one(struct pci_dev *pdev)
 				    instance->vf_affiliation_111,
 				    instance->vf_affiliation_111_h);
 
-	if (instance->hb_host_mem)
-		dma_free_coherent(&pdev->dev, sizeof(struct MR_CTRL_HB_HOST_MEM),
-				    instance->hb_host_mem,
-				    instance->hb_host_mem_h);
-
 	megasas_free_ctrl_dma_buffers(instance);
 
 	megasas_free_ctrl_mem(instance);

-- 
2.25.1


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

end of thread, other threads:[~2026-09-04  9:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04  9:27 [PATCH] scsi: megaraid_sas: fix hb_host_mem leak on init failure Li Youhong
2026-09-04  9:47 ` sashiko-bot

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