Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Kashyap Desai <kashyap.desai@broadcom.com>,
	Sumit Saxena <sumit.saxena@broadcom.com>,
	Shivasharan S <shivasharan.srikanteshwara@broadcom.com>,
	Chandrakanth patil <chandrakanth.patil@broadcom.com>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Arnd Bergmann <arnd@arndb.de>
Cc: Dan Carpenter <error27@gmail.com>,
	megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] scsi: megaraid_mbox: avoid double kfree()
Date: Mon,  1 Jun 2026 23:02:04 +0200	[thread overview]
Message-ID: <20260601210216.846809-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.de>

Smatch found a double-free after my recent change:

	drivers/scsi/megaraid/megaraid_mbox.c:3474 megaraid_cmm_register()
	error: double free of 'adp' (line 3468)

Since the object is no longer allocated in megaraid_cmm_register(),
remove the kfree() as well.

Fixes: c1f7275b613b ("scsi: megaraid_mbox: Reduce stack usage in megaraid_cmm_register()")
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/megaraid/megaraid_mm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 60db48dc8f3a..e572665903d2 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -998,8 +998,6 @@ mraid_mm_register_adp(mraid_mmadp_t *adapter)
 
 	dma_pool_destroy(adapter->pthru_dma_pool);
 
-	kfree(adapter);
-
 	return rval;
 }
 
-- 
2.39.5


             reply	other threads:[~2026-06-01 21:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 21:02 Arnd Bergmann [this message]
2026-06-02  1:55 ` [PATCH] scsi: megaraid_mbox: avoid double kfree() Martin K. Petersen

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=20260601210216.846809-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=arnd@arndb.de \
    --cc=chandrakanth.patil@broadcom.com \
    --cc=error27@gmail.com \
    --cc=kashyap.desai@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=megaraidlinux.pdl@broadcom.com \
    --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