From patchwork Sat Dec 26 06:45:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 11990261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 715EBC433DB for ; Sat, 26 Dec 2020 06:46:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07CB6207B5 for ; Sat, 26 Dec 2020 06:46:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07CB6207B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Eo0OrRFrofB9D3ylx5wr1nq1Cy39WQByAyE+nWB1cO4=; b=PMKb72+FtOVEiPu82D3/BXkX6 Z4zq49wJrx+caerwMwKLLdYDPKjxSJJ/lpOou92diYq8wy2wHQrjU/+vAE2koai2REdZ+u3+pcGpb Y4KUVAgYnvG+0RCfWLujx6GXyYziAoZv5CW/DYVyj9FdZytiNRMcWVSx9v8Yn8bsQzzhfLH1VTU/g 5gBy948MwOwDyvf9n7jW3TQcu5WxMpkSEJe9oywAOxeAaDyMdh3PUTcw4QkxibxjWAo9HQ8q3kqjK SAK18HaaP1NeyrnIOqIExBnuaKDyFyJ+dAp9QGY0vsYJ25Hqcebuq84lj+fw7JvN9FTGNVjyl8aSr UCi2jtTvQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kt3Kf-0007UV-99; Sat, 26 Dec 2020 06:45:41 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kt3Kc-0007TR-GS for linux-arm-kernel@lists.infradead.org; Sat, 26 Dec 2020 06:45:39 +0000 Received: by mail-pf1-x436.google.com with SMTP id m6so3480146pfm.6 for ; Fri, 25 Dec 2020 22:45:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vnMHu5Qy0Jg58UtwP7Ds62Ap6snjXtPHHHu3PtC/XEo=; b=dlG38EeVZacFRmy6FQi7N0YYOYZ+6eAIjVXaWVZVoDb/X30UBODrFuDWaVxw513N8K xUDYQ9fPv2JiKVd2HvG0xPmmk6KiJkc/JLQbw/A4lV3uMc2DGf3BBqUxQm/GTD21rp0f jB3aM8+L0oUzFSmMGmw+x+dc4KwRPkv6ut5pScK989Usi2C65croYz/sMmZrlLINUaS/ KjVTKVqhmd7HfIw098Fjn1Txo6kNLA8AQ83MALlX7V9ug7pk279QAuQnBUJ4NqK5laDQ 77RwdH5b906TtQcQ7PyDn12ZgVu3GjU85rdDRDyjwOElwUX7IccZKgSnV6S61fB0+SGm lJ1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vnMHu5Qy0Jg58UtwP7Ds62Ap6snjXtPHHHu3PtC/XEo=; b=n4cySAdS9kmZSpPk32wtnyQ7o7JZ6rtUCUOb19W/2CL/54VLKIBUl+hntXgTCCsJvF lw1YLm/AEL1b4dayB4gAwh+0+3HkSRvVCVChm8Mcx5h1LJEb6Mqmm98H7SMboRga+Jvj Uqu6phsMOA7zXySf2ROO8QhvIMNJQeVmEmDPlqu9gEbPh5MDFGlx43BnRAVxBhMXhE+A PlKn1wyjBu0U1k9CD6yX20mMJQqr5Lao/ul2QhpVDcBud/AMjlPTZJTPpo+gBHznegyM NwaQat/ZSo1AsHmgflLYs1g1mK9FhOXFozYg4b1ufW/uI7CukO1rS4cAZgWrMsPjzxcj wCXQ== X-Gm-Message-State: AOAM530GYeUtek9iR7v00Tub7gInjEzHD00z8PAuiR0gkaCcpbIEZZSr FZL8NQ8dob/hESlLemKlVAg= X-Google-Smtp-Source: ABdhPJws3YsPWlyumseJrN1/+szleyhO7fW1OuHDB/pTEgqDVu+reDMNMWH3EsSevnPoXVaiAEw6uw== X-Received: by 2002:a63:cf56:: with SMTP id b22mr35606537pgj.16.1608965136522; Fri, 25 Dec 2020 22:45:36 -0800 (PST) Received: from syed.domain.name ([103.201.127.53]) by smtp.gmail.com with ESMTPSA id cq15sm6935227pjb.27.2020.12.25.22.45.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Dec 2020 22:45:36 -0800 (PST) Date: Sat, 26 Dec 2020 12:15:20 +0530 From: Syed Nayyar Waris To: linus.walleij@linaro.org Subject: [PATCH 5/5] gpio: xilinx: Add extra check if sum of widths exceed 64 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201226_014538_580239_29818F3B X-CRM114-Status: GOOD ( 13.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, amit.kucheria@verdurent.com, arnd@arndb.de, yamada.masahiro@socionext.com, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, daniel.lezcano@linaro.org, vilhelm.gray@gmail.com, michal.simek@xilinx.com, bgolaszewski@baylibre.com, rrichter@marvell.com, linux-gpio@vger.kernel.org, linux-pm@vger.kernel.org, akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, rui.zhang@intel.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add extra check to see if sum of widths does not exceed 64. If it exceeds then return -EINVAL alongwith appropriate error message. Cc: Michal Simek Signed-off-by: Syed Nayyar Waris Acked-by: Michal Simek --- drivers/gpio/gpio-xilinx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index d565fbf128b7..c9d740ac711b 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -319,6 +319,12 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.base = -1; chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1]; + + if (chip->gc.ngpio > 64) { + dev_err(&pdev->dev, "invalid configuration: number of GPIO is greater than 64"); + return -EINVAL; + } + chip->gc.parent = &pdev->dev; chip->gc.direction_input = xgpio_dir_in; chip->gc.direction_output = xgpio_dir_out;