Skip to contentSkip to conversation

drivers/fsi: Don't scan after fsi-gpio-master unbound

PATCH Superseded Christopher Bostic 2 participants 2 messages Mar 1, 2017 – Mar 2, 2017 FSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/fsi: Don't scan after fsi-gpio-master unbound

Check pointers prior to scanning master in the sysfs scan file. These get invalidated after an unbind operation.

---
 drivers/fsi/fsi-master-gpio.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/fsi/fsi-master-gpio.c +8 -1
index c5f4f9c..67f0d9d 100644
@@ -476,7 +476,14 @@ static ssize_t store_scan(struct device *dev,
 				const char *buf,
 				size_t count)
 {
-	struct fsi_master_gpio *master = dev_get_drvdata(dev);
+	struct fsi_master_gpio *master;
+
+	if (!dev)
+		return count;
+
+	master = dev_get_drvdata(dev);
+	if (!master)
+		return count;
 
 	fsi_master_gpio_init(master);
 
Signature · 1 line
1.8.2.2
#1 lore raw
Quoted 15 lines · Christopher Bostic

Check pointers prior to scanning master in the sysfs scan file. These get invalidated after an unbind operation.

---
 drivers/fsi/fsi-master-gpio.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/fsi/fsi-master-gpio.c +0 -0
index c5f4f9c..67f0d9d 100644
@@ -476,7 +476,14 @@ static ssize_t store_scan(struct device *dev,
                                const char *buf,
                                size_t count)

drivers/fsi/fsi-master-gpio.c static ssize_t store_scan(struct device *dev, · line 486

Quoted 10 lines
drivers/fsi/fsi-master-gpio.c +8 -1
 {
-       struct fsi_master_gpio *master = dev_get_drvdata(dev);
+       struct fsi_master_gpio *master;
+
+       if (!dev)
+               return count;
+
+       master = dev_get_drvdata(dev);
+       if (!master)
+               return count;

Returning count implies that you've stored the data the user has written. You should return an error in the case where there is an error.

Cheers,

Joel

Quoted 6 lines
drivers/fsi/fsi-master-gpio.c +0 -1
        fsi_master_gpio_init(master);
 
--

1.8.2.2