linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: single: check for any error when getting rows
@ 2016-11-09 14:17 Axel Haslam
  2016-11-09 15:19 ` Tony Lindgren
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Haslam @ 2016-11-09 14:17 UTC (permalink / raw)
  To: tony, haojian.zhuang, linus.walleij, khilman, nsekhar
  Cc: linux-arm-kernel, linux-omap, linux-gpio, linux-kernel, Axel Haslam

pinctrl_count_index_with_args returns -ENOENT not
-EINVAL. The return check would pass, and we would
try to kzalloc with a negative error size throwing
a warning.

Instead of checking for -EINVAL specifically, lets
check for any error and avoid negative size allocations.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
 drivers/pinctrl/pinctrl-single.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 539f31c..56e22be 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1228,7 +1228,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 	struct pcs_function *function;
 
 	rows = pinctrl_count_index_with_args(np, name);
-	if (rows == -EINVAL)
+	if (rows < 0)
 		return rows;
 
 	npins_in_row = pcs->width / pcs->bits_per_pin;
-- 
2.10.1

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

* Re: [PATCH] pinctrl: single: check for any error when getting rows
  2016-11-09 14:17 [PATCH] pinctrl: single: check for any error when getting rows Axel Haslam
@ 2016-11-09 15:19 ` Tony Lindgren
  0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2016-11-09 15:19 UTC (permalink / raw)
  To: Axel Haslam
  Cc: haojian.zhuang, linus.walleij, khilman, nsekhar,
	linux-arm-kernel, linux-omap, linux-gpio, linux-kernel

* Axel Haslam <ahaslam@baylibre.com> [161109 07:19]:
> pinctrl_count_index_with_args returns -ENOENT not
> -EINVAL. The return check would pass, and we would
> try to kzalloc with a negative error size throwing
> a warning.
> 
> Instead of checking for -EINVAL specifically, lets
> check for any error and avoid negative size allocations.
> 
> Signed-off-by: Axel Haslam <ahaslam@baylibre.com>

Thanks for fixing that:

Acked-by: Tony Lindgren <tony@atomide.com>

> ---
>  drivers/pinctrl/pinctrl-single.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index 539f31c..56e22be 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -1228,7 +1228,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
>  	struct pcs_function *function;
>  
>  	rows = pinctrl_count_index_with_args(np, name);
> -	if (rows == -EINVAL)
> +	if (rows < 0)
>  		return rows;
>  
>  	npins_in_row = pcs->width / pcs->bits_per_pin;
> -- 
> 2.10.1
> 

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

end of thread, other threads:[~2016-11-09 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-09 14:17 [PATCH] pinctrl: single: check for any error when getting rows Axel Haslam
2016-11-09 15:19 ` Tony Lindgren

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).