gpio: rtd: Fix signedness bug in probe

Message ID 46566e85-4afa-4c55-93b2-0d0b71d76b12@moroto.mountain
State New
Headers
Series gpio: rtd: Fix signedness bug in probe |

Commit Message

Dan Carpenter Jan. 12, 2024, 6:55 a.m. UTC
  The "data->irqs[]" array holds unsigned int so this error handling will
not work correctly.

Fixes: eee636bff0dc ("gpio: rtd: Add support for Realtek DHC(Digital Home Center) RTD SoCs")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/gpio/gpio-rtd.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
  

Comments

Linus Walleij Jan. 12, 2024, 10:25 a.m. UTC | #1
On Fri, Jan 12, 2024 at 7:55 AM Dan Carpenter <dan.carpenter@linaroorg> wrote:

> The "data->irqs[]" array holds unsigned int so this error handling will
> not work correctly.
>
> Fixes: eee636bff0dc ("gpio: rtd: Add support for Realtek DHC(Digital Home Center) RTD SoCs")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Looks right to me!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
  
Bartosz Golaszewski Jan. 15, 2024, 10:08 a.m. UTC | #2
On Fri, Jan 12, 2024 at 7:55 AM Dan Carpenter <dan.carpenter@linaroorg> wrote:
>
> The "data->irqs[]" array holds unsigned int so this error handling will
> not work correctly.
>
> Fixes: eee636bff0dc ("gpio: rtd: Add support for Realtek DHC(Digital Home Center) RTD SoCs")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/gpio/gpio-rtd.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpio/gpio-rtd.c b/drivers/gpio/gpio-rtd.c
> index a7939bd0aa56..bf7f008f58d7 100644
> --- a/drivers/gpio/gpio-rtd.c
> +++ b/drivers/gpio/gpio-rtd.c
> @@ -525,18 +525,21 @@ static int rtd_gpio_probe(struct platform_device *pdev)
>         struct device *dev = &pdev->dev;
>         struct gpio_irq_chip *irq_chip;
>         struct rtd_gpio *data;
> +       int ret;
>
>         data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
>         if (!data)
>                 return -ENOMEM;
>
> -       data->irqs[0] = platform_get_irq(pdev, 0);
> -       if (data->irqs[0] < 0)
> -               return data->irqs[0];
> +       ret = platform_get_irq(pdev, 0);
> +       if (ret < 0)
> +               return ret;
> +       data->irqs[0] = ret;
>
> -       data->irqs[1] = platform_get_irq(pdev, 1);
> -       if (data->irqs[1] < 0)
> -               return data->irqs[1];
> +       ret = platform_get_irq(pdev, 1);
> +       if (ret < 0)
> +               return ret;
> +       data->irqs[1] = ret;
>
>         data->info = device_get_match_data(dev);
>         if (!data->info)
> --
> 2.43.0
>

Applied, thanks!

Bartosz
  

Patch

diff --git a/drivers/gpio/gpio-rtd.c b/drivers/gpio/gpio-rtd.c
index a7939bd0aa56..bf7f008f58d7 100644
--- a/drivers/gpio/gpio-rtd.c
+++ b/drivers/gpio/gpio-rtd.c
@@ -525,18 +525,21 @@  static int rtd_gpio_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct gpio_irq_chip *irq_chip;
 	struct rtd_gpio *data;
+	int ret;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
-	data->irqs[0] = platform_get_irq(pdev, 0);
-	if (data->irqs[0] < 0)
-		return data->irqs[0];
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0)
+		return ret;
+	data->irqs[0] = ret;
 
-	data->irqs[1] = platform_get_irq(pdev, 1);
-	if (data->irqs[1] < 0)
-		return data->irqs[1];
+	ret = platform_get_irq(pdev, 1);
+	if (ret < 0)
+		return ret;
+	data->irqs[1] = ret;
 
 	data->info = device_get_match_data(dev);
 	if (!data->info)