All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: axp209: dereference pointer after it's been set
@ 2017-12-13  8:55 ` Quentin Schulz
  0 siblings, 0 replies; 7+ messages in thread
From: Quentin Schulz @ 2017-12-13  8:55 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A, wens-jdAy2FN1RRM,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
  Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

The number of GPIOs is gotten from a field within the structure
referenced in the of_device.data but it was actually read before it was
retrieved, thus it was dereferencing a null pointer.

Set the number of GPIOs after retrieving of_device.data.

Fixes: e1190083b89b ("pinctrl: axp209: add support for AXP813 GPIOs")

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Reported-by: Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 drivers/pinctrl/pinctrl-axp209.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 22d3bb0bf927..510a2821e910 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -413,9 +413,11 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	pctl->chip.set			= axp20x_gpio_set;
 	pctl->chip.direction_input	= axp20x_gpio_input;
 	pctl->chip.direction_output	= axp20x_gpio_output;
-	pctl->chip.ngpio		= pctl->desc->npins;
 
 	pctl->desc = (struct axp20x_pctrl_desc *)of_device_get_match_data(dev);
+
+	pctl->chip.ngpio		= pctl->desc->npins;
+
 	pctl->regmap = axp20x->regmap;
 	pctl->dev = &pdev->dev;
 
-- 
2.14.1

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

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

* [PATCH] pinctrl: axp209: dereference pointer after it's been set
@ 2017-12-13  8:55 ` Quentin Schulz
  0 siblings, 0 replies; 7+ messages in thread
From: Quentin Schulz @ 2017-12-13  8:55 UTC (permalink / raw)
  To: linus.walleij, wens, maxime.ripard
  Cc: linux-gpio, linux-kernel, thomas.petazzoni, linux-sunxi,
	mylene.josserand, Quentin Schulz

The number of GPIOs is gotten from a field within the structure
referenced in the of_device.data but it was actually read before it was
retrieved, thus it was dereferencing a null pointer.

Set the number of GPIOs after retrieving of_device.data.

Fixes: e1190083b89b ("pinctrl: axp209: add support for AXP813 GPIOs")

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Reported-by: Mylène Josserand <mylene.josserand@free-electrons.com>
---
 drivers/pinctrl/pinctrl-axp209.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
index 22d3bb0bf927..510a2821e910 100644
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -413,9 +413,11 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
 	pctl->chip.set			= axp20x_gpio_set;
 	pctl->chip.direction_input	= axp20x_gpio_input;
 	pctl->chip.direction_output	= axp20x_gpio_output;
-	pctl->chip.ngpio		= pctl->desc->npins;
 
 	pctl->desc = (struct axp20x_pctrl_desc *)of_device_get_match_data(dev);
+
+	pctl->chip.ngpio		= pctl->desc->npins;
+
 	pctl->regmap = axp20x->regmap;
 	pctl->dev = &pdev->dev;
 
-- 
2.14.1

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

* Re: [PATCH] pinctrl: axp209: dereference pointer after it's been set
  2017-12-13  8:55 ` Quentin Schulz
@ 2017-12-13  9:20     ` Mylene JOSSERAND
  -1 siblings, 0 replies; 7+ messages in thread
From: Mylene JOSSERAND @ 2017-12-13  9:20 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A, wens-jdAy2FN1RRM,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

Hello Quentin,

Le Wed, 13 Dec 2017 09:55:03 +0100,
Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> a écrit :

> The number of GPIOs is gotten from a field within the structure
> referenced in the of_device.data but it was actually read before it was
> retrieved, thus it was dereferencing a null pointer.
> 
> Set the number of GPIOs after retrieving of_device.data.
> 
> Fixes: e1190083b89b ("pinctrl: axp209: add support for AXP813 GPIOs")
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Reported-by: Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Tested-by: Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Thanks,

Mylène

> ---
>  drivers/pinctrl/pinctrl-axp209.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
> index 22d3bb0bf927..510a2821e910 100644
> --- a/drivers/pinctrl/pinctrl-axp209.c
> +++ b/drivers/pinctrl/pinctrl-axp209.c
> @@ -413,9 +413,11 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
>  	pctl->chip.set			= axp20x_gpio_set;
>  	pctl->chip.direction_input	= axp20x_gpio_input;
>  	pctl->chip.direction_output	= axp20x_gpio_output;
> -	pctl->chip.ngpio		= pctl->desc->npins;
>  
>  	pctl->desc = (struct axp20x_pctrl_desc *)of_device_get_match_data(dev);
> +
> +	pctl->chip.ngpio		= pctl->desc->npins;
> +
>  	pctl->regmap = axp20x->regmap;
>  	pctl->dev = &pdev->dev;
>  

-- 
Mylène Josserand, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH] pinctrl: axp209: dereference pointer after it's been set
@ 2017-12-13  9:20     ` Mylene JOSSERAND
  0 siblings, 0 replies; 7+ messages in thread
From: Mylene JOSSERAND @ 2017-12-13  9:20 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linus.walleij, wens, maxime.ripard, linux-gpio, linux-kernel,
	thomas.petazzoni, linux-sunxi

Hello Quentin,

Le Wed, 13 Dec 2017 09:55:03 +0100,
Quentin Schulz <quentin.schulz@free-electrons.com> a écrit :

> The number of GPIOs is gotten from a field within the structure
> referenced in the of_device.data but it was actually read before it was
> retrieved, thus it was dereferencing a null pointer.
> 
> Set the number of GPIOs after retrieving of_device.data.
> 
> Fixes: e1190083b89b ("pinctrl: axp209: add support for AXP813 GPIOs")
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> Reported-by: Mylène Josserand <mylene.josserand@free-electrons.com>

Tested-by: Mylène Josserand <mylene.josserand@free-electrons.com>

Thanks,

Mylène

> ---
>  drivers/pinctrl/pinctrl-axp209.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
> index 22d3bb0bf927..510a2821e910 100644
> --- a/drivers/pinctrl/pinctrl-axp209.c
> +++ b/drivers/pinctrl/pinctrl-axp209.c
> @@ -413,9 +413,11 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
>  	pctl->chip.set			= axp20x_gpio_set;
>  	pctl->chip.direction_input	= axp20x_gpio_input;
>  	pctl->chip.direction_output	= axp20x_gpio_output;
> -	pctl->chip.ngpio		= pctl->desc->npins;
>  
>  	pctl->desc = (struct axp20x_pctrl_desc *)of_device_get_match_data(dev);
> +
> +	pctl->chip.ngpio		= pctl->desc->npins;
> +
>  	pctl->regmap = axp20x->regmap;
>  	pctl->dev = &pdev->dev;
>  

-- 
Mylène Josserand, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH] pinctrl: axp209: dereference pointer after it's been set
  2017-12-13  9:20     ` Mylene JOSSERAND
@ 2017-12-14  3:05         ` Chen-Yu Tsai
  -1 siblings, 0 replies; 7+ messages in thread
From: Chen-Yu Tsai @ 2017-12-14  3:05 UTC (permalink / raw)
  To: Mylene JOSSERAND
  Cc: Quentin Schulz, Linus Walleij, Chen-Yu Tsai, Maxime Ripard,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA, linux-kernel,
	Thomas Petazzoni, linux-sunxi

On Wed, Dec 13, 2017 at 5:20 PM, Mylene JOSSERAND
<mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> wrote:
> Hello Quentin,
>
> Le Wed, 13 Dec 2017 09:55:03 +0100,
> Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> a écrit :
>
>> The number of GPIOs is gotten from a field within the structure
>> referenced in the of_device.data but it was actually read before it was
>> retrieved, thus it was dereferencing a null pointer.
>>
>> Set the number of GPIOs after retrieving of_device.data.
>>
>> Fixes: e1190083b89b ("pinctrl: axp209: add support for AXP813 GPIOs")
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>> Reported-by: Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>
> Tested-by: Mylène Josserand <mylene.josserand-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Acked-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

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

* Re: [PATCH] pinctrl: axp209: dereference pointer after it's been set
@ 2017-12-14  3:05         ` Chen-Yu Tsai
  0 siblings, 0 replies; 7+ messages in thread
From: Chen-Yu Tsai @ 2017-12-14  3:05 UTC (permalink / raw)
  To: Mylene JOSSERAND
  Cc: Quentin Schulz, Linus Walleij, Chen-Yu Tsai, Maxime Ripard,
	linux-gpio, linux-kernel, Thomas Petazzoni, linux-sunxi

On Wed, Dec 13, 2017 at 5:20 PM, Mylene JOSSERAND
<mylene.josserand@free-electrons.com> wrote:
> Hello Quentin,
>
> Le Wed, 13 Dec 2017 09:55:03 +0100,
> Quentin Schulz <quentin.schulz@free-electrons.com> a écrit :
>
>> The number of GPIOs is gotten from a field within the structure
>> referenced in the of_device.data but it was actually read before it was
>> retrieved, thus it was dereferencing a null pointer.
>>
>> Set the number of GPIOs after retrieving of_device.data.
>>
>> Fixes: e1190083b89b ("pinctrl: axp209: add support for AXP813 GPIOs")
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>> Reported-by: Mylène Josserand <mylene.josserand@free-electrons.com>
>
> Tested-by: Mylène Josserand <mylene.josserand@free-electrons.com>

Acked-by: Chen-Yu Tsai <wens@csie.org>

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

* Re: [PATCH] pinctrl: axp209: dereference pointer after it's been set
  2017-12-13  8:55 ` Quentin Schulz
  (?)
  (?)
@ 2017-12-20  8:07 ` Linus Walleij
  -1 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2017-12-20  8:07 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: Chen-Yu Tsai, Maxime Ripard, linux-gpio, linux-kernel,
	Thomas Petazzoni, linux-sunxi, Mylene Josserand

On Wed, Dec 13, 2017 at 9:55 AM, Quentin Schulz
<quentin.schulz@free-electrons.com> wrote:

> The number of GPIOs is gotten from a field within the structure
> referenced in the of_device.data but it was actually read before it was
> retrieved, thus it was dereferencing a null pointer.
>
> Set the number of GPIOs after retrieving of_device.data.
>
> Fixes: e1190083b89b ("pinctrl: axp209: add support for AXP813 GPIOs")
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> Reported-by: Mylène Josserand <mylene.josserand@free-electrons.com>

Patch applied with the tags for test and ACK.

Yours,
Linus Walleij

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

end of thread, other threads:[~2017-12-20  8:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13  8:55 [PATCH] pinctrl: axp209: dereference pointer after it's been set Quentin Schulz
2017-12-13  8:55 ` Quentin Schulz
     [not found] ` <20171213085503.31899-1-quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-12-13  9:20   ` Mylene JOSSERAND
2017-12-13  9:20     ` Mylene JOSSERAND
     [not found]     ` <20171213102048.1c7e3b7f-K8i4uRanGBt8XcdJbWeDu7NAH6kLmebB@public.gmane.org>
2017-12-14  3:05       ` Chen-Yu Tsai
2017-12-14  3:05         ` Chen-Yu Tsai
2017-12-20  8:07 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.