diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-30 20:22:47 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-30 20:22:47 +0200 |
commit | 8b8c877febd2610050758f1b7b97050a7d2dc794 (patch) | |
tree | 8c47cb2bbc0ede9c9616eed76042e052eb828131 | |
parent | Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide (diff) | |
parent | hwmon: (max1111) Return -ENODEV from max1111_read_channel if not instantiated (diff) | |
download | linux-8b8c877febd2610050758f1b7b97050a7d2dc794.tar.xz linux-8b8c877febd2610050758f1b7b97050a7d2dc794.zip |
Merge tag 'hwmon-for-linus-v4.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fix from Guenter Roeck:
"Fix crash due to NULL pointer access in max1111 driver"
* tag 'hwmon-for-linus-v4.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
hwmon: (max1111) Return -ENODEV from max1111_read_channel if not instantiated
-rw-r--r-- | drivers/hwmon/max1111.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/hwmon/max1111.c b/drivers/hwmon/max1111.c index 36544c4f653c..303d0c9df907 100644 --- a/drivers/hwmon/max1111.c +++ b/drivers/hwmon/max1111.c @@ -85,6 +85,9 @@ static struct max1111_data *the_max1111; int max1111_read_channel(int channel) { + if (!the_max1111 || !the_max1111->spi) + return -ENODEV; + return max1111_read(&the_max1111->spi->dev, channel); } EXPORT_SYMBOL(max1111_read_channel); @@ -258,6 +261,9 @@ static int max1111_remove(struct spi_device *spi) { struct max1111_data *data = spi_get_drvdata(spi); +#ifdef CONFIG_SHARPSL_PM + the_max1111 = NULL; +#endif hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&spi->dev.kobj, &max1110_attr_group); sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); |