Skip to content

Commit 8b8c877

Browse files
committed
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
2 parents 1993b17 + 3c2e226 commit 8b8c877

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/hwmon/max1111.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ static struct max1111_data *the_max1111;
8585

8686
int max1111_read_channel(int channel)
8787
{
88+
if (!the_max1111 || !the_max1111->spi)
89+
return -ENODEV;
90+
8891
return max1111_read(&the_max1111->spi->dev, channel);
8992
}
9093
EXPORT_SYMBOL(max1111_read_channel);
@@ -258,6 +261,9 @@ static int max1111_remove(struct spi_device *spi)
258261
{
259262
struct max1111_data *data = spi_get_drvdata(spi);
260263

264+
#ifdef CONFIG_SHARPSL_PM
265+
the_max1111 = NULL;
266+
#endif
261267
hwmon_device_unregister(data->hwmon_dev);
262268
sysfs_remove_group(&spi->dev.kobj, &max1110_attr_group);
263269
sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group);

0 commit comments

Comments
 (0)