From patchwork Mon Mar 28 19:04:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Mostafa X-Patchwork-Id: 602579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3qYjy21rtjz9s48; Tue, 29 Mar 2016 06:04:26 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1akcSX-0003EY-ER; Mon, 28 Mar 2016 19:04:17 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1akcSS-0003Dd-0z for kernel-team@lists.ubuntu.com; Mon, 28 Mar 2016 19:04:12 +0000 Received: from 1.general.kamal.us.vpn ([10.172.68.52] helo=fourier) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1akcSR-0003nV-Ii; Mon, 28 Mar 2016 19:04:11 +0000 Received: from kamal by fourier with local (Exim 4.86_2) (envelope-from ) id 1akcSO-0002td-Mz; Mon, 28 Mar 2016 12:04:08 -0700 From: Kamal Mostafa To: Bamvor Jian Zhang Subject: [4.2.y-ckt stable] Patch "gpiolib: do not allow to insert an empty gpiochip" has been added to the 4.2.y-ckt tree Date: Mon, 28 Mar 2016 12:04:07 -0700 Message-Id: <1459191847-11098-1-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 2.7.4 X-Extended-Stable: 4.2 Cc: Linus Walleij , Kamal Mostafa , kernel-team@lists.ubuntu.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com This is a note to let you know that I have just added a patch titled gpiolib: do not allow to insert an empty gpiochip to the linux-4.2.y-queue branch of the 4.2.y-ckt extended stable tree which can be found at: http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-4.2.y-queue This patch is scheduled to be released in version 4.2.8-ckt7. If you, or anyone else, feels it should not be added to this tree, please reply to this email. For more information about the 4.2.y-ckt tree, see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable Thanks. -Kamal ---8<------------------------------------------------------------ From 31d98a9aaaa7d359e78259ce76eabba55f78df11 Mon Sep 17 00:00:00 2001 From: Bamvor Jian Zhang Date: Mon, 16 Nov 2015 13:02:47 +0800 Subject: gpiolib: do not allow to insert an empty gpiochip commit 5ed41cc4baaf4127661d2a8f8f2ee6e3085e0fa9 upstream. We need to check if number of gpio is positive if there is no such check in devicetree or acpi or whatever called before gpiochip_add. I suppose that devicetree and acpi do not allow insert gpiochip with zero number but I do not know if it is enough to ignore this check in gpiochip_add. Signed-off-by: Bamvor Jian Zhang Signed-off-by: Linus Walleij [ kamal: 4.2-stable prereq ] Signed-off-by: Kamal Mostafa --- drivers/gpio/gpiolib.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.4 diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index bf4bd1d..3144d19 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -247,6 +247,11 @@ int gpiochip_add(struct gpio_chip *chip) if (!descs) return -ENOMEM; + if (chip->ngpio == 0) { + chip_err(chip, "tried to insert a GPIO chip with zero lines\n"); + return -EINVAL; + } + spin_lock_irqsave(&gpio_lock, flags); if (base < 0) {