diff options
author | Eddie James <eajames@linux.ibm.com> | 2023-08-09 20:08:14 +0200 |
---|---|---|
committer | Joel Stanley <joel@jms.id.au> | 2023-08-11 06:02:14 +0200 |
commit | b1d3a803acfa900611d5a1393fc4aef801cb1385 (patch) | |
tree | afa4c49642196c9d7d0af2f752c9c15e84db97cd /drivers/fsi | |
parent | fsi: Improve master indexing (diff) | |
download | linux-b1d3a803acfa900611d5a1393fc4aef801cb1385.tar.xz linux-b1d3a803acfa900611d5a1393fc4aef801cb1385.zip |
fsi: Lock mutex for master device registration
Because master device registration may cause hub master scans, or
user scans may begin before device registration has ended, so the
master scan lock must be held while registering the device.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230809180814.151984-3-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
Diffstat (limited to 'drivers/fsi')
-rw-r--r-- | drivers/fsi/fsi-core.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 90872e2e78d1..097d5a780264 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1326,20 +1326,20 @@ int fsi_master_register(struct fsi_master *master) master->dev.class = &fsi_master_class; + mutex_lock(&master->scan_lock); rc = device_register(&master->dev); if (rc) { ida_free(&master_ida, master->idx); - return rc; + goto out; } np = dev_of_node(&master->dev); if (!of_property_read_bool(np, "no-scan-on-init")) { - mutex_lock(&master->scan_lock); fsi_master_scan(master); - mutex_unlock(&master->scan_lock); } - - return 0; +out: + mutex_unlock(&master->scan_lock); + return rc; } EXPORT_SYMBOL_GPL(fsi_master_register); |