From patchwork Mon Nov 16 05:02:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bamvor Zhang Jian X-Patchwork-Id: 56567 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1114103lbb; Sun, 15 Nov 2015 21:03:06 -0800 (PST) X-Received: by 10.66.188.49 with SMTP id fx17mr51287912pac.95.1447650186193; Sun, 15 Nov 2015 21:03:06 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6si47645951pap.162.2015.11.15.21.03.05; Sun, 15 Nov 2015 21:03:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750729AbbKPFDF (ORCPT + 4 others); Mon, 16 Nov 2015 00:03:05 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:33210 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750712AbbKPFDE (ORCPT ); Mon, 16 Nov 2015 00:03:04 -0500 Received: by pabfh17 with SMTP id fh17so164607670pab.0 for ; Sun, 15 Nov 2015 21:03:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AKwzUdLgrNAPqtszRP/Fbourr/bvbB+//HeIlVhTd1k=; b=KPa0qdpUe9ULW8gvHUo/wA4wICOpmoPH0hlDrM4ZinKK+QszbkGEqikv2mL7ZuhkOx Fpx/G0KPUzlBXhiG50EYqVEmrBlvEso/n3m7aLpM8LjXE4gXNVA9otuZzWDoCbPM8nNQ /dxeZsjK4EwsopEkUhl/rCP/tWlY8KpcmCfA/n+Y3KRkv1D2E/j8pbpBgUivpa03bPX+ c5fW6nejZDvQ2Jei/v5K3welc6pNmoPU0Ts/TUFxV0c0DEAFns4UPblGcTkYC5xwoMVg 2CWFFFbK0w4Cx2bMMC97V9z+mWOqOGtSmjjoQvAeh3K2/z1kC714ZkIVHD7mhR97O4R8 SDcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AKwzUdLgrNAPqtszRP/Fbourr/bvbB+//HeIlVhTd1k=; b=c2ILARu4F+LkIf938mRSFWTlty4ktpIIy+AneH41qwmH5dknFTmrIlSQSYjrk+qg75 YROHcUI+NiChmui6fc1ibq/jnhWoz+/mulXvXklnXpvEqVqOz1bKlfweoe+im0bE7wu/ yMFnHR4CDSQHatgla3f4Ueviy+bsa5LS1trAETwr0wTRxlEjMMxytYdPJu8QToJtMeiM HA089A1Dw99GJrj2FdWl9bf1PyQmV7YbrvT/if6zuwBPymW30LHCl0EPwtM5A8gysJ2O XJ/9jWxz7HDwAMotejdvunSg3aNKdUaCx7wQkvV5KR2SHGnQymQeyLfwW4iUx6rGZTu1 62gg== X-Gm-Message-State: ALoCoQnEHgzVMGS8GfwLlMyzBf3v7kE3mFRjYkU5zx+lLte/h13SX7vwuXXRvCjN5/xK3G8GzNnA X-Received: by 10.68.193.165 with SMTP id hp5mr50849790pbc.20.1447650184341; Sun, 15 Nov 2015 21:03:04 -0800 (PST) Received: from linux-j170.site (li844-78.members.linode.com. [139.162.2.78]) by smtp.gmail.com with ESMTPSA id yg2sm33355959pbb.79.2015.11.15.21.03.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Nov 2015 21:03:03 -0800 (PST) From: Bamvor Jian Zhang To: linux-gpio@vger.kernel.org Cc: linus.walleij@linaro.org, broonie@kernel.org, Bamvor Jian Zhang Subject: [PATCH V2 2/2] gpiolib: do not allow to insert an empty gpiochip Date: Mon, 16 Nov 2015 13:02:47 +0800 Message-Id: <1447650167-29070-3-git-send-email-bamvor.zhangjian@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447650167-29070-1-git-send-email-bamvor.zhangjian@linaro.org> References: <1447650167-29070-1-git-send-email-bamvor.zhangjian@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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 --- drivers/gpio/gpiolib.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 270d60b..150af91 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -329,6 +329,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) {