diff options
author | Bart Van Assche <bvanassche@acm.org> | 2021-12-03 15:19:39 -0800 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2021-12-06 22:30:33 -0500 |
commit | 21ad0e49085deb22c094f91f9da57319a97188e4 (patch) | |
tree | 29743ea1c2c88e816f0df6dfc60c17f6dd4f5c41 /drivers/scsi/ufs/ufshcd.c | |
parent | d77ea8226b3be23b0b45aa42851243b62a27bda1 (diff) | |
download | linux-21ad0e49085deb22c094f91f9da57319a97188e4.tar.gz linux-21ad0e49085deb22c094f91f9da57319a97188e4.tar.bz2 linux-21ad0e49085deb22c094f91f9da57319a97188e4.zip |
scsi: ufs: Fix race conditions related to driver data
The driver data pointer must be set before any callbacks are registered
that use that pointer. Hence move the initialization of that pointer from
after the ufshcd_init() call to inside ufshcd_init().
Link: https://lore.kernel.org/r/20211203231950.193369-7-bvanassche@acm.org
Fixes: 3b1d05807a9a ("[SCSI] ufs: Segregate PCI Specific Code")
Reported-by: Alexey Dobriyan <adobriyan@gmail.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/ufs/ufshcd.c')
-rw-r--r-- | drivers/scsi/ufs/ufshcd.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index d4996ada55b6..04a19b826837 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -9481,6 +9481,13 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) struct device *dev = hba->dev; char eh_wq_name[sizeof("ufs_eh_wq_00")]; + /* + * dev_set_drvdata() must be called before any callbacks are registered + * that use dev_get_drvdata() (frequency scaling, clock scaling, hwmon, + * sysfs). + */ + dev_set_drvdata(dev, hba); + if (!mmio_base) { dev_err(hba->dev, "Invalid memory reference for mmio_base is NULL\n"); |