From: Changyul Lee <lcy8047@gmail.com>
To: Alex Dubov <oakad@yahoo.com>, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Changyul Lee <lcy8047@gmail.com>
Subject: [PATCH] misc: tifm: Remove the adapter ID after device_del()
Date: Mon, 9 Nov 2026 13:48:32 -0500 [thread overview]
Message-ID: <20261109184832.1256641-1-lcy8047@gmail.com> (raw)
tifm_remove_adapter() removes the adapter ID from tifm_adapter_idr
before device_del() removes the "tifm<N>" device. An adapter added in
between, for example by another TI FlashMedia controller being probed,
can get the same ID, and its device_add() fails:
sysfs: cannot create duplicate filename '/class/tifm_adapter/tifm0'
Remove the ID after device_del(), as the error path of
tifm_add_adapter() already does.
Fixes: 6113ed73e61a ("tifm: move common adapter management tasks from tifm_7xx1 to tifm_core")
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
---
Found with a static analysis tool we are developing.
Reproduced in QEMU (x86_64) with a test module that runs two kthreads
for 20 seconds. Each kthread allocates, adds, removes and frees an
adapter in a loop, under its own platform device as the parent.
Without this patch, tifm_add_adapter() failed with -EEXIST 125066 to
126356 times per run in three runs. With it, it never failed in three
runs.
Not tested on TI FlashMedia hardware.
drivers/misc/tifm_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index 03d1324bc253..91f9b377588d 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -223,10 +223,10 @@ void tifm_remove_adapter(struct tifm_adapter *fm)
device_unregister(&fm->sockets[cnt]->dev);
}
+ device_del(&fm->dev);
spin_lock(&tifm_adapter_lock);
idr_remove(&tifm_adapter_idr, fm->id);
spin_unlock(&tifm_adapter_lock);
- device_del(&fm->dev);
}
EXPORT_SYMBOL(tifm_remove_adapter);
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
--
2.43.0
reply other threads:[~2026-11-09 18:48 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=20261109184832.1256641-1-lcy8047@gmail.com \
--to=lcy8047@gmail.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oakad@yahoo.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
all inboxes | Powered by JetHome®