Thread (18 messages) 18 messages, 7 authors, 2021-01-06
STALE2010d
Revisions (2)
  1. v2 [diff vs current]
  2. v1 current

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

From: Syed Nayyar Waris <hidden>
Date: 2020-12-26 06:46:18
Also in: linux-arch, linux-gpio, linux-pm, lkml
Subsystem: gpio subsystem, the rest, xilinx gpio driver · Maintainers: Linus Walleij, Bartosz Golaszewski, Linus Torvalds, Shubhrajyoti Datta

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 <redacted>
Signed-off-by: Syed Nayyar Waris <redacted>
---
 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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help