linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] gpio: dwapb: fix NULL pointer dereference at dwapb_gpio_suspend()
@ 2020-11-27  8:50 Luo Jiaxing
  2020-11-30 16:42 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Luo Jiaxing @ 2020-11-27  8:50 UTC (permalink / raw)
  To: bgolaszewski, linus.walleij, Sergey.Semin
  Cc: andy.shevchenko, andriy.shevchenko, linux-gpio, linux-kernel, linuxarm

Following Calltrace is found when running echo freeze > /sys/power/state.

[  272.755506] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
[  272.755585] Call trace:
[  272.755587]  dwapb_gpio_suspend+0x18/0x318
[  272.755588]  pm_generic_suspend+0x2c/0x48
[  272.755595]  acpi_subsys_suspend+0x60/0x70
[  272.755599]  dpm_run_callback.isra.18+0x40/0xe0
[  272.755601]  __device_suspend+0xf4/0x360

The reason is platform_set_drvdata() is deleted, and dwapb_gpio_suspend()
get *gpio by dev_get_drvdata().

Fixes: feeaefd378ca ("gpio: dwapb: Use resource managed GPIO-chip add data method")
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Acked-by: Serge Semin <fancer.lancer@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

---
   v1->v2:
          1. reduce calltrace log
          2. delete blank line in tag block
---
---
 drivers/gpio/gpio-dwapb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index 2a9046c..4275c18 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -724,6 +724,8 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
 			return err;
 	}
 
+	platform_set_drvdata(pdev, gpio);
+
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] gpio: dwapb: fix NULL pointer dereference at dwapb_gpio_suspend()
  2020-11-27  8:50 [PATCH v2] gpio: dwapb: fix NULL pointer dereference at dwapb_gpio_suspend() Luo Jiaxing
@ 2020-11-30 16:42 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2020-11-30 16:42 UTC (permalink / raw)
  To: Luo Jiaxing
  Cc: Linus Walleij, Sergey.Semin, Andy Shevchenko, Andy Shevchenko,
	linux-gpio, LKML, linuxarm

On Fri, Nov 27, 2020 at 9:50 AM Luo Jiaxing <luojiaxing@huawei.com> wrote:
>
> Following Calltrace is found when running echo freeze > /sys/power/state.
>
> [  272.755506] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
> [  272.755585] Call trace:
> [  272.755587]  dwapb_gpio_suspend+0x18/0x318
> [  272.755588]  pm_generic_suspend+0x2c/0x48
> [  272.755595]  acpi_subsys_suspend+0x60/0x70
> [  272.755599]  dpm_run_callback.isra.18+0x40/0xe0
> [  272.755601]  __device_suspend+0xf4/0x360
>
> The reason is platform_set_drvdata() is deleted, and dwapb_gpio_suspend()
> get *gpio by dev_get_drvdata().
>
> Fixes: feeaefd378ca ("gpio: dwapb: Use resource managed GPIO-chip add data method")
> Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
> Acked-by: Serge Semin <fancer.lancer@gmail.com>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> ---
>    v1->v2:
>           1. reduce calltrace log
>           2. delete blank line in tag block
> ---
> ---
>  drivers/gpio/gpio-dwapb.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
> index 2a9046c..4275c18 100644
> --- a/drivers/gpio/gpio-dwapb.c
> +++ b/drivers/gpio/gpio-dwapb.c
> @@ -724,6 +724,8 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
>                         return err;
>         }
>
> +       platform_set_drvdata(pdev, gpio);
> +
>         return 0;
>  }
>
> --
> 2.7.4
>

Applied, thanks!

Bartosz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-30 16:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27  8:50 [PATCH v2] gpio: dwapb: fix NULL pointer dereference at dwapb_gpio_suspend() Luo Jiaxing
2020-11-30 16:42 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).