public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: l1za0.sec@gmail.com
To: mcgrof@kernel.org, russ.weight@linux.dev, gregkh@linuxfoundation.org
Cc: rafael@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] drivers: firmware_loader: fix race between sysfs fallback cleanup and device removal
Date: Tue, 21 Apr 2026 21:49:57 +0800	[thread overview]
Message-ID: <20260421135013.36322-1-l1za0.sec@gmail.com> (raw)

From: Haocheng Yu <l1za0.sec@gmail.com>

A WARNING in firmware_fallback_sysfs is reported by a modified
Syzkaller-based kernel fuzzing tool that we developed.

The cause of this issue is a possible race condition between
firmware sysfs fallback cleanup and hot-plug or other device
lifecycle paths.

In this case, fw_load_sysfs_fallback() might run cleanup after the
fallback device has already been removed, i.e., it would execute
device_del(), then dpm_sysfs_remove(), and finally trigger a
warning in sysfs_remove_group().

This problem can be avoided by adding device_is_registered()
check before calling device_del().

Signed-off-by: Haocheng Yu <l1za0.sec@gmail.com>
---
 drivers/base/firmware_loader/fallback.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c
index bf68e3947814..a8d8c494f82d 100644
--- a/drivers/base/firmware_loader/fallback.c
+++ b/drivers/base/firmware_loader/fallback.c
@@ -116,8 +116,9 @@ static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs, long timeout)
 	} else if (fw_priv->is_paged_buf && !fw_priv->data)
 		retval = -ENOMEM;
 
-out:
-	device_del(f_dev);
+out:
+	if (device_is_registered(f_dev))
+		device_del(f_dev);
 err_put_dev:
 	put_device(f_dev);
 	return retval;

base-commit: ffc253263a1375a65fa6c9f62a893e9767fbebfa
-- 
2.51.0


             reply	other threads:[~2026-04-21 13:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21 13:49 l1za0.sec [this message]
2026-04-21 14:14 ` [PATCH] drivers: firmware_loader: fix race between sysfs fallback cleanup and device removal Greg KH
2026-04-22 11:36   ` Li Zao
2026-04-22 11:52     ` Greg KH

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=20260421135013.36322-1-l1za0.sec@gmail.com \
    --to=l1za0.sec@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=rafael@kernel.org \
    --cc=russ.weight@linux.dev \
    /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