From: ahaslam@baylibre.com (Axel Haslam)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] pinctrl: single: check for any error when getting rows
Date: Wed, 9 Nov 2016 15:54:00 +0100 [thread overview]
Message-ID: <20161109145401.25327-2-ahaslam@baylibre.com> (raw)
In-Reply-To: <20161109145401.25327-1-ahaslam@baylibre.com>
pinctrl_count_index_with_args returns -ENOENT not
-EINVAL. The return check would pass, and we would
try to kzalloc with a negative error size throwing
a warning.
Instead of checking for -EINVAL specifically, lets
check for any error and avoid negative size allocations.
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
drivers/pinctrl/pinctrl-single.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 539f31c..f36a9f1 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1133,8 +1133,10 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
struct pcs_function *function;
rows = pinctrl_count_index_with_args(np, name);
- if (rows == -EINVAL)
- return rows;
+ if (rows <= 0) {
+ dev_err(pcs->dev, "Ivalid number of rows: %d\n", rows);
+ return -EINVAL;
+ }
vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows, GFP_KERNEL);
if (!vals)
@@ -1228,8 +1230,10 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
struct pcs_function *function;
rows = pinctrl_count_index_with_args(np, name);
- if (rows == -EINVAL)
- return rows;
+ if (rows <= 0) {
+ dev_err(pcs->dev, "Invalid number of rows: %d\n", rows);
+ return -EINVAL;
+ }
npins_in_row = pcs->width / pcs->bits_per_pin;
--
2.10.1
next prev parent reply other threads:[~2016-11-09 14:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-09 14:53 [PATCH v2 0/2] pinctrl: single: fixes for davinci Axel Haslam
2016-11-09 14:54 ` Axel Haslam [this message]
2016-11-11 20:29 ` [PATCH v2 1/2] pinctrl: single: check for any error when getting rows Linus Walleij
2016-11-09 14:54 ` [PATCH v2 2/2] pinctrl: single: search for the bits property when parsing bits Axel Haslam
2016-11-11 20:30 ` Linus Walleij
2016-11-09 15:20 ` [PATCH v2 0/2] pinctrl: single: fixes for davinci Tony Lindgren
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=20161109145401.25327-2-ahaslam@baylibre.com \
--to=ahaslam@baylibre.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox