public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eddie James <eajames@linux.ibm.com>
To: linux-fsi@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org, joel@jms.id.au, jk@ozlabs.org,
	alistair@popple.id.au, Eddie James <eajames@linux.ibm.com>
Subject: [PATCH 1/2] fsi: core: Lock scan mutex for master index removal
Date: Wed, 12 Apr 2023 13:56:01 -0500	[thread overview]
Message-ID: <20230412185602.1592629-2-eajames@linux.ibm.com> (raw)
In-Reply-To: <20230412185602.1592629-1-eajames@linux.ibm.com>

If a master scan occurs while the master is being unregistered,
the devicecs may end up with incorrect and possibly duplicate names,
resulting in kernel warnings. Ensure the master index isn't changed
outside of the scan mutex.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/fsi/fsi-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index fcbf0469ce3f..18d4d68482d7 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -1354,12 +1354,12 @@ EXPORT_SYMBOL_GPL(fsi_master_register);
 
 void fsi_master_unregister(struct fsi_master *master)
 {
+	mutex_lock(&master->scan_lock);
 	if (master->idx >= 0) {
 		ida_simple_remove(&master_ida, master->idx);
 		master->idx = -1;
 	}
 
-	mutex_lock(&master->scan_lock);
 	fsi_master_unscan(master);
 	mutex_unlock(&master->scan_lock);
 	device_unregister(&master->dev);
-- 
2.31.1


  reply	other threads:[~2023-04-12 18:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12 18:56 [PATCH 0/2] fsi: core: Lock scan mutex for master index removal Eddie James
2023-04-12 18:56 ` Eddie James [this message]
2023-05-31  7:47   ` [PATCH 1/2] " Joel Stanley
2023-06-08 16:45     ` Eddie James
2023-04-12 18:56 ` [PATCH 2/2] fsi: core: Add trace events for scan and unregister Eddie James
2023-05-31  1:52   ` Joel Stanley

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=20230412185602.1592629-2-eajames@linux.ibm.com \
    --to=eajames@linux.ibm.com \
    --cc=alistair@popple.id.au \
    --cc=jk@ozlabs.org \
    --cc=joel@jms.id.au \
    --cc=linux-fsi@lists.ozlabs.org \
    --cc=linux-kernel@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