All of lore.kernel.org
 help / color / mirror / Atom feed
From: Syed Nayyar Waris <syednwaris@gmail.com>
To: linus.walleij@linaro.org, akpm@linux-foundation.org
Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com,
	michal.simek@xilinx.com, arnd@arndb.de, rrichter@marvell.com,
	linus.walleij@linaro.org, bgolaszewski@baylibre.com,
	yamada.masahiro@socionext.com, rui.zhang@intel.com,
	daniel.lezcano@linaro.org, amit.kucheria@verdurent.com,
	linux-arch@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org
Subject: [PATCH v2 2/2] gpio: xilinx: Add extra check if sum of widths exceed 64
Date: Sat, 12 Dec 2020 15:04:54 +0530	[thread overview]
Message-ID: <7049b151670d3cb3ca190185bb484a79b2d5d845.1607765148.git.syednwaris@gmail.com> (raw)
In-Reply-To: <cover.1607765147.git.syednwaris@gmail.com>

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 05dae086c4d0..a2e92a1cf50b 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -340,6 +340,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


WARNING: multiple messages have this Message-ID (diff)
From: Syed Nayyar Waris <syednwaris@gmail.com>
To: linus.walleij@linaro.org, akpm@linux-foundation.org
Cc: linux-arch@vger.kernel.org, amit.kucheria@verdurent.com,
	arnd@arndb.de, yamada.masahiro@socionext.com,
	linux-kernel@vger.kernel.org, linus.walleij@linaro.org,
	daniel.lezcano@linaro.org, vilhelm.gray@gmail.com,
	michal.simek@xilinx.com, bgolaszewski@baylibre.com,
	rrichter@marvell.com, linux-gpio@vger.kernel.org,
	linux-pm@vger.kernel.org, rui.zhang@intel.com,
	andriy.shevchenko@linux.intel.com,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/2] gpio: xilinx: Add extra check if sum of widths exceed 64
Date: Sat, 12 Dec 2020 15:04:54 +0530	[thread overview]
Message-ID: <7049b151670d3cb3ca190185bb484a79b2d5d845.1607765148.git.syednwaris@gmail.com> (raw)
In-Reply-To: <cover.1607765147.git.syednwaris@gmail.com>

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 05dae086c4d0..a2e92a1cf50b 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -340,6 +340,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

  parent reply	other threads:[~2020-12-12 10:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12  9:33 [PATCH v2 0/2] Modify bitmap_set_value() to suppress compiler warning Syed Nayyar Waris
2020-12-12  9:33 ` Syed Nayyar Waris
2020-12-12  9:34 ` [PATCH v2 1/2] bitmap: Modify bitmap_set_value() to check bitmap length Syed Nayyar Waris
2020-12-12  9:34   ` Syed Nayyar Waris
2020-12-12 15:56   ` kernel test robot
2020-12-12 17:05   ` kernel test robot
2020-12-13 14:55   ` Andy Shevchenko
2020-12-13 14:55     ` Andy Shevchenko
2020-12-12  9:34 ` Syed Nayyar Waris [this message]
2020-12-12  9:34   ` [PATCH v2 2/2] gpio: xilinx: Add extra check if sum of widths exceed 64 Syed Nayyar Waris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7049b151670d3cb3ca190185bb484a79b2d5d845.1607765148.git.syednwaris@gmail.com \
    --to=syednwaris@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=amit.kucheria@verdurent.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=bgolaszewski@baylibre.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=rrichter@marvell.com \
    --cc=rui.zhang@intel.com \
    --cc=vilhelm.gray@gmail.com \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.