All of lore.kernel.org
 help / color / mirror / Atom feed
From: <gregkh@linuxfoundation.org>
To: linus.walleij@linaro.org, gregkh@linuxfoundation.org,
	hdegoede@redhat.com, maxime.ripard@free-electrons.com
Cc: <stable@vger.kernel.org>, <stable-commits@vger.kernel.org>
Subject: Patch "gpio: make sure gpiod_to_irq() returns negative on NULL desc" has been added to the 4.6-stable tree
Date: Thu, 23 Jun 2016 19:51:11 -0700	[thread overview]
Message-ID: <146673667115556@kroah.com> (raw)


This is a note to let you know that I've just added the patch titled

    gpio: make sure gpiod_to_irq() returns negative on NULL desc

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-make-sure-gpiod_to_irq-returns-negative-on-null-desc.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 79bb71bd1d93197ce227fa167b450b633f30a52b Mon Sep 17 00:00:00 2001
From: Linus Walleij <linus.walleij@linaro.org>
Date: Wed, 15 Jun 2016 22:57:38 +0200
Subject: gpio: make sure gpiod_to_irq() returns negative on NULL desc

From: Linus Walleij <linus.walleij@linaro.org>

commit 79bb71bd1d93197ce227fa167b450b633f30a52b upstream.

commit 54d77198fdfbc4f0fe11b4252c1d9c97d51a3264
("gpio: bail out silently on NULL descriptors")
doesn't work for gpiod_to_irq(): drivers assume that NULL
descriptors will give negative IRQ numbers in return.

It has been pointed out that returning 0 is NO_IRQ and that
drivers should be amended to treat this as an error, but that
is for the longer term: now let us repair the semantics.

Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Reported-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpio/gpiolib.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2006,7 +2006,14 @@ int gpiod_to_irq(const struct gpio_desc
 	struct gpio_chip	*chip;
 	int			offset;
 
-	VALIDATE_DESC(desc);
+	/*
+	 * Cannot VALIDATE_DESC() here as gpiod_to_irq() consumer semantics
+	 * requires this function to not return zero on an invalid descriptor
+	 * but rather a negative error number.
+	 */
+	if (!desc || !desc->gdev || !desc->gdev->chip)
+		return -EINVAL;
+
 	chip = desc->gdev->chip;
 	offset = gpio_chip_hwgpio(desc);
 	return chip->to_irq ? chip->to_irq(chip, offset) : -ENXIO;


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-zynq-fix-the-error-path.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/gpio-zynq-initialize-clock-even-without-config_pm.patch
queue-4.6/gpio-make-sure-gpiod_to_irq-returns-negative-on-null-desc.patch
queue-4.6/gpiolib-fix-null-pointer-deference.patch

                 reply	other threads:[~2016-06-24  2:51 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=146673667115556@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=linus.walleij@linaro.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=stable-commits@vger.kernel.org \
    --cc=stable@vger.kernel.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 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.