diff options
author | Miquel Raynal <miquel.raynal@free-electrons.com> | 2017-10-16 08:12:10 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2017-10-29 21:36:03 -0400 |
commit | 534e28d876926669bba0dc31519a0b0026f3dfcb (patch) | |
tree | 9af4f9eed950d984347ac578aa0ce359c7f71318 | |
parent | 9de382fddf18f673436f1058d822e1236a0b4c2a (diff) |
hwmon: (gpio-fan) Fix null pointer dereference at probe
A previous commit changed the argument list of gpio_fan_get_of_data(),
removing the "struct *dev" argument and retrieving it instead from the
gpio_fan_data structure. The "dev" entry of gpio_fan_data was then
dereferenced to access the of_node field, leading to a kernel panic
during the probe as the "dev" entry of the gpio_fan_data structure was
not filled yet.
Fix this by setting fan_data->dev before calling gpio_fan_get_of_data().
Fixes: 5859d8d30737 ("hwmon: (gpio-fan) Get rid of platform data struct")
Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/gpio-fan.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index 43b697380987..5c9a52599cf6 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c | |||
@@ -510,11 +510,11 @@ static int gpio_fan_probe(struct platform_device *pdev) | |||
510 | if (!fan_data) | 510 | if (!fan_data) |
511 | return -ENOMEM; | 511 | return -ENOMEM; |
512 | 512 | ||
513 | fan_data->dev = dev; | ||
513 | err = gpio_fan_get_of_data(fan_data); | 514 | err = gpio_fan_get_of_data(fan_data); |
514 | if (err) | 515 | if (err) |
515 | return err; | 516 | return err; |
516 | 517 | ||
517 | fan_data->dev = dev; | ||
518 | platform_set_drvdata(pdev, fan_data); | 518 | platform_set_drvdata(pdev, fan_data); |
519 | mutex_init(&fan_data->lock); | 519 | mutex_init(&fan_data->lock); |
520 | 520 | ||