Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: "Li Youhong" <dayou5941@163.com>
To: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com,
	shivasharan.srikanteshwara@broadcom.com,
	chandrakanth.patil@broadcom.com
Cc: James.Bottomley@HansenPartnership.com, mkp@kernel.org,
	megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
	Li Youhong <liyouhong@kylinos.cn>
Subject: [PATCH] scsi: megaraid_sas: fix hb_host_mem leak on init failure
Date: Fri,  4 Sep 2026 17:27:40 +0800	[thread overview]
Message-ID: <20260904092740.2612033-1-dayou5941@163.com> (raw)

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


             reply	other threads:[~2026-09-04  9:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  9:27 Li Youhong [this message]
2026-09-04  9:47 ` [PATCH] scsi: megaraid_sas: fix hb_host_mem leak on init failure sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260904092740.2612033-1-dayou5941@163.com \
    --to=dayou5941@163.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=chandrakanth.patil@broadcom.com \
    --cc=kashyap.desai@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=liyouhong@kylinos.cn \
    --cc=megaraidlinux.pdl@broadcom.com \
    --cc=mkp@kernel.org \
    --cc=shivasharan.srikanteshwara@broadcom.com \
    --cc=sumit.saxena@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox