diff mbox series

pinctrl: at91: fix a couple NULL vs IS_ERR() checks

Message ID 5697980e-f687-47a7-9db8-2af34ae464bd@kili.mountain
State Accepted
Commit 35216718c9ac2aef934ea9cd229572d4996807b2
Headers show
Series pinctrl: at91: fix a couple NULL vs IS_ERR() checks | expand

Commit Message

Dan Carpenter May 22, 2023, 7:44 a.m. UTC
The devm_kasprintf_strarray() function doesn't return NULL on error,
it returns error pointers.  Update the checks accordingly.

Fixes: f494c1913cbb ("pinctrl: at91: use devm_kasprintf() to avoid potential leaks (part 2)")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/pinctrl/pinctrl-at91.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Andy Shevchenko May 22, 2023, 9:18 p.m. UTC | #1
On Mon, May 22, 2023 at 10:44:54AM +0300, Dan Carpenter wrote:
> The devm_kasprintf_strarray() function doesn't return NULL on error,
> it returns error pointers.  Update the checks accordingly.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks!

> Fixes: f494c1913cbb ("pinctrl: at91: use devm_kasprintf() to avoid potential leaks (part 2)")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/pinctrl/pinctrl-at91.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index 871209c24153..39956d821ad7 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -1389,8 +1389,8 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
>  		char **names;
>  
>  		names = devm_kasprintf_strarray(dev, "pio", MAX_NB_GPIO_PER_BANK);
> -		if (!names)
> -			return -ENOMEM;
> +		if (IS_ERR(names))
> +			return PTR_ERR(names);
>  
>  		for (j = 0; j < MAX_NB_GPIO_PER_BANK; j++, k++) {
>  			char *name = names[j];
> @@ -1870,8 +1870,8 @@ static int at91_gpio_probe(struct platform_device *pdev)
>  	}
>  
>  	names = devm_kasprintf_strarray(dev, "pio", chip->ngpio);
> -	if (!names)
> -		return -ENOMEM;
> +	if (IS_ERR(names))
> +		return PTR_ERR(names);
>  
>  	for (i = 0; i < chip->ngpio; i++)
>  		strreplace(names[i], '-', alias_idx + 'A');
> -- 
> 2.39.2
>
Ryan Wanner May 22, 2023, 10:20 p.m. UTC | #2
On 5/22/23 00:44, Dan Carpenter wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> The devm_kasprintf_strarray() function doesn't return NULL on error,
> it returns error pointers.  Update the checks accordingly.
> 
> Fixes: f494c1913cbb ("pinctrl: at91: use devm_kasprintf() to avoid potential leaks (part 2)")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Ryan Wanner <ryan.wanner@microchip.com>
> ---
>  drivers/pinctrl/pinctrl-at91.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index 871209c24153..39956d821ad7 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -1389,8 +1389,8 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
>                 char **names;
> 
>                 names = devm_kasprintf_strarray(dev, "pio", MAX_NB_GPIO_PER_BANK);
> -               if (!names)
> -                       return -ENOMEM;
> +               if (IS_ERR(names))
> +                       return PTR_ERR(names);
> 
>                 for (j = 0; j < MAX_NB_GPIO_PER_BANK; j++, k++) {
>                         char *name = names[j];
> @@ -1870,8 +1870,8 @@ static int at91_gpio_probe(struct platform_device *pdev)
>         }
> 
>         names = devm_kasprintf_strarray(dev, "pio", chip->ngpio);
> -       if (!names)
> -               return -ENOMEM;
> +       if (IS_ERR(names))
> +               return PTR_ERR(names);
> 
>         for (i = 0; i < chip->ngpio; i++)
>                 strreplace(names[i], '-', alias_idx + 'A');
> --
> 2.39.2
>
Claudiu Beznea May 23, 2023, 5:01 a.m. UTC | #3
On 22.05.2023 10:44, Dan Carpenter wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> The devm_kasprintf_strarray() function doesn't return NULL on error,
> it returns error pointers.  Update the checks accordingly.
> 
> Fixes: f494c1913cbb ("pinctrl: at91: use devm_kasprintf() to avoid potential leaks (part 2)")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>


> ---
>  drivers/pinctrl/pinctrl-at91.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index 871209c24153..39956d821ad7 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -1389,8 +1389,8 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
>                 char **names;
> 
>                 names = devm_kasprintf_strarray(dev, "pio", MAX_NB_GPIO_PER_BANK);
> -               if (!names)
> -                       return -ENOMEM;
> +               if (IS_ERR(names))
> +                       return PTR_ERR(names);
> 
>                 for (j = 0; j < MAX_NB_GPIO_PER_BANK; j++, k++) {
>                         char *name = names[j];
> @@ -1870,8 +1870,8 @@ static int at91_gpio_probe(struct platform_device *pdev)
>         }
> 
>         names = devm_kasprintf_strarray(dev, "pio", chip->ngpio);
> -       if (!names)
> -               return -ENOMEM;
> +       if (IS_ERR(names))
> +               return PTR_ERR(names);
> 
>         for (i = 0; i < chip->ngpio; i++)
>                 strreplace(names[i], '-', alias_idx + 'A');
> --
> 2.39.2
>
Linus Walleij May 24, 2023, 8:51 a.m. UTC | #4
On Mon, May 22, 2023 at 9:45 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:

> The devm_kasprintf_strarray() function doesn't return NULL on error,
> it returns error pointers.  Update the checks accordingly.
>
> Fixes: f494c1913cbb ("pinctrl: at91: use devm_kasprintf() to avoid potential leaks (part 2)")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Patch applied.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 871209c24153..39956d821ad7 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1389,8 +1389,8 @@  static int at91_pinctrl_probe(struct platform_device *pdev)
 		char **names;
 
 		names = devm_kasprintf_strarray(dev, "pio", MAX_NB_GPIO_PER_BANK);
-		if (!names)
-			return -ENOMEM;
+		if (IS_ERR(names))
+			return PTR_ERR(names);
 
 		for (j = 0; j < MAX_NB_GPIO_PER_BANK; j++, k++) {
 			char *name = names[j];
@@ -1870,8 +1870,8 @@  static int at91_gpio_probe(struct platform_device *pdev)
 	}
 
 	names = devm_kasprintf_strarray(dev, "pio", chip->ngpio);
-	if (!names)
-		return -ENOMEM;
+	if (IS_ERR(names))
+		return PTR_ERR(names);
 
 	for (i = 0; i < chip->ngpio; i++)
 		strreplace(names[i], '-', alias_idx + 'A');