diff mbox series

[5/5] gpio: xilinx: Add extra check if sum of widths exceed 64

Message ID fd642c0843d59a0091931fcf9baa19a9dbb6e2e7.1608963095.git.syednwaris@gmail.com
State New
Headers show
Series Introduce the for_each_set_clump macro | expand

Commit Message

Syed Nayyar Waris Dec. 26, 2020, 6:45 a.m. UTC
Add extra check to see if sum of widths does not exceed 64. If it
exceeds then return -EINVAL alongwith appropriate error message.

Cc: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com>
---
 drivers/gpio/gpio-xilinx.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

William Breathitt Gray Dec. 28, 2020, 11:58 a.m. UTC | #1
On Sat, Dec 26, 2020 at 12:15:20PM +0530, Syed Nayyar Waris wrote:
> Add extra check to see if sum of widths does not exceed 64. If it

> exceeds then return -EINVAL alongwith appropriate error message.

> 

> Cc: Michal Simek <michal.simek@xilinx.com>

> Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com>


Hello Syed,

This change is independent from the rest of this patchset so I recommend
dropping this patch and instead resubmitting it separately as an
independent patch submission.

William Breathitt Gray

> ---

>  drivers/gpio/gpio-xilinx.c | 6 ++++++

>  1 file changed, 6 insertions(+)

> 

> diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c

> index d565fbf128b7..c9d740ac711b 100644

> --- a/drivers/gpio/gpio-xilinx.c

> +++ b/drivers/gpio/gpio-xilinx.c

> @@ -319,6 +319,12 @@ static int xgpio_probe(struct platform_device *pdev)

>  

>  	chip->gc.base = -1;

>  	chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1];

> +

> +	if (chip->gc.ngpio > 64) {

> +		dev_err(&pdev->dev, "invalid configuration: number of GPIO is greater than 64");

> +			return -EINVAL;

> +	}

> +

>  	chip->gc.parent = &pdev->dev;

>  	chip->gc.direction_input = xgpio_dir_in;

>  	chip->gc.direction_output = xgpio_dir_out;

> -- 

> 2.29.0

>
Michal Simek Jan. 5, 2021, 11:01 a.m. UTC | #2
On 26. 12. 20 7:45, Syed Nayyar Waris wrote:
> Add extra check to see if sum of widths does not exceed 64. If it
> exceeds then return -EINVAL alongwith appropriate error message.
> 
> Cc: Michal Simek <michal.simek@xilinx.com>
> Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com>
> ---
>  drivers/gpio/gpio-xilinx.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
> index d565fbf128b7..c9d740ac711b 100644
> --- a/drivers/gpio/gpio-xilinx.c
> +++ b/drivers/gpio/gpio-xilinx.c
> @@ -319,6 +319,12 @@ static int xgpio_probe(struct platform_device *pdev)
>  
>  	chip->gc.base = -1;
>  	chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1];
> +
> +	if (chip->gc.ngpio > 64) {
> +		dev_err(&pdev->dev, "invalid configuration: number of GPIO is greater than 64");
> +			return -EINVAL;
> +	}
> +
>  	chip->gc.parent = &pdev->dev;
>  	chip->gc.direction_input = xgpio_dir_in;
>  	chip->gc.direction_output = xgpio_dir_out;
> 

Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index d565fbf128b7..c9d740ac711b 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -319,6 +319,12 @@  static int xgpio_probe(struct platform_device *pdev)
 
 	chip->gc.base = -1;
 	chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1];
+
+	if (chip->gc.ngpio > 64) {
+		dev_err(&pdev->dev, "invalid configuration: number of GPIO is greater than 64");
+			return -EINVAL;
+	}
+
 	chip->gc.parent = &pdev->dev;
 	chip->gc.direction_input = xgpio_dir_in;
 	chip->gc.direction_output = xgpio_dir_out;