From: <gregkh@linuxfoundation.org>
To: linus.walleij@linaro.org, andrew@lunn.ch, f.fainelli@gmail.com,
gregkh@linuxfoundation.org, sergei.shtylyov@cogentembedded.com,
u.kleine-koenig@pengutronix.de
Cc: <stable@vger.kernel.org>, <stable-commits@vger.kernel.org>
Subject: Patch "gpio: bail out silently on NULL descriptors" has been added to the 4.6-stable tree
Date: Sat, 18 Jun 2016 10:02:54 -0700 [thread overview]
Message-ID: <1466269374217165@kroah.com> (raw)
This is a note to let you know that I've just added the patch titled
gpio: bail out silently on NULL descriptors
to the 4.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
gpio-bail-out-silently-on-null-descriptors.patch
and it can be found in the queue-4.6 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
>From 54d77198fdfbc4f0fe11b4252c1d9c97d51a3264 Mon Sep 17 00:00:00 2001
From: Linus Walleij <linus.walleij@linaro.org>
Date: Mon, 30 May 2016 16:48:39 +0200
Subject: gpio: bail out silently on NULL descriptors
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Linus Walleij <linus.walleij@linaro.org>
commit 54d77198fdfbc4f0fe11b4252c1d9c97d51a3264 upstream.
In fdeb8e1547cb9dd39d5d7223b33f3565cf86c28e
("gpio: reflect base and ngpio into gpio_device")
assumed that GPIO descriptors are either valid or error
pointers, but gpiod_get_[index_]optional() actually return
NULL descriptors and then all subsequent calls should just
bail out.
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Fixes: fdeb8e1547cb ("gpio: reflect base and ngpio into gpio_device")
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpio/gpiolib.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1339,10 +1339,13 @@ done:
/*
* This descriptor validation needs to be inserted verbatim into each
* function taking a descriptor, so we need to use a preprocessor
- * macro to avoid endless duplication.
+ * macro to avoid endless duplication. If the desc is NULL it is an
+ * optional GPIO and calls should just bail out.
*/
#define VALIDATE_DESC(desc) do { \
- if (!desc || !desc->gdev) { \
+ if (!desc) \
+ return 0; \
+ if (!desc->gdev) { \
pr_warn("%s: invalid GPIO\n", __func__); \
return -EINVAL; \
} \
@@ -1353,7 +1356,9 @@ done:
} } while (0)
#define VALIDATE_DESC_VOID(desc) do { \
- if (!desc || !desc->gdev) { \
+ if (!desc) \
+ return; \
+ if (!desc->gdev) { \
pr_warn("%s: invalid GPIO\n", __func__); \
return; \
} \
Patches currently in stable-queue which might be from linus.walleij@linaro.org are
queue-4.6/gpiolib-fix-unaligned-used-of-reference-counters.patch
queue-4.6/gpio-bcm-kona-fix-bcm_kona_gpio_reset-warnings.patch
queue-4.6/pinctrl-mediatek-fix-dual-edge-code-defect.patch
queue-4.6/gpio-bail-out-silently-on-null-descriptors.patch
queue-4.6/gpiolib-fix-null-pointer-deference.patch
reply other threads:[~2016-06-18 17:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1466269374217165@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=stable-commits@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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.