Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Johannes Berg <johannes@sipsolutions.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Johan Hovold <johan@kernel.org>
Cc: driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH] devcoredump: fix double free on device registration failure
Date: Mon,  2 Nov 2026 09:25:36 +0100	[thread overview]
Message-ID: <20261102082536.1275223-1-johan@kernel.org> (raw)

The device coredump class release function devcd_dev_release() puts the
module reference and frees the data so just return after dropping the
device reference on registration failures to avoid a module reference
imbalance and double free.

This issue was flagged by an LLM.

Fixes: 833c95456a70 ("device coredump: add new device coredump class")
Cc: stable@vger.kernel.org	# 3.18
Cc: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/base/devcoredump.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c
index 8bb1763083dd..16e99ac926a7 100644
--- a/drivers/base/devcoredump.c
+++ b/drivers/base/devcoredump.c
@@ -433,10 +433,12 @@ void dev_coredumpm_timeout(struct device *dev, struct module *owner,
 	devcd->init_completed = true;
 	mutex_unlock(&devcd->mutex);
 	return;
+
  put_device:
 	mutex_unlock(&devcd->mutex);
 	cancel_delayed_work_sync(&devcd->del_wk);
 	put_device(&devcd->devcd_dev);
+	return;
 
  put_module:
 	module_put(owner);
-- 
2.55.0


                 reply	other threads:[~2026-11-02  8:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261102082536.1275223-1-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=stable@vger.kernel.org \
    /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