From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 B5262C433FE for ; Sat, 12 Dec 2020 10:06:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86295207C9 for ; Sat, 12 Dec 2020 10:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438567AbgLLKFc (ORCPT ); Sat, 12 Dec 2020 05:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407213AbgLLJyQ (ORCPT ); Sat, 12 Dec 2020 04:54:16 -0500 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53F8CC0619D7; Sat, 12 Dec 2020 01:35:14 -0800 (PST) Received: by mail-pj1-x1042.google.com with SMTP id j13so3751306pjz.3; Sat, 12 Dec 2020 01:35:14 -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=Yy8mAP2XRxcUpsdCsTm+KdTXMmpuQJot11SefIetIN0=; b=KVDtSO/0uKi/QiWrCU1zn8LcujpIvT+dkAK6HUZ93j38/Q+wLHDfplKTgdiVbzeMtl flByeS8IhAqGaM4xzRwM1ErjEBytK51Eg7hcFne7vL3kiWZmIyO/VkSa0yE+wUmO3MkY 2ItDX5YGfJy/zCkHG/K1SNWKWcXmkK5BKcaxahXVVDp3319WZrlDHTa7JcZ6RGEnDo9L 9KpEh5kKl8IsgVn++gvfaaAqXza+k2fziihzv68mnliqi6+CiuxyDxTLWh8bZelMx+Gf B4nt6ssW7RkPVJPXZbSRdJJKVmkaqHvOchQ0OstcveZPVYVbtQLpHlD3u/5ncYpbr69R TYDg== 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=Yy8mAP2XRxcUpsdCsTm+KdTXMmpuQJot11SefIetIN0=; b=bk3+knL4U9bhqDBJwzaL/N0u2YblpCxS187ZdpUj15APvZMw4IwKWc4kLkmqO83zAa 3Otn2ussVMKOqOV+XbJfRJbfDpbtFBOOY4WN6PBtJz+hFeIklolPTsUt2oq5JjbkhN7a mKxZmVIvsVZupdhv7YczlmkJTSyZf5I/P4v2qs8cubYa/OvrWN0yC0+nOGQxR10UCFG1 Y6qIBUO4U9ltzX2GqihD8qItgyGlkCGpyZwUCPyLSH9xioC6JS+lE7TNR3EDTt3bCpjM fmy2IER1P9Cir8d/dfI4enBxxcHh0+wobBapv0qxoaHGfcsqXngfb2OmfCxh1GNUEIJ+ SJ2g== X-Gm-Message-State: AOAM531GKna2FmUudOuxsR/nl4eIPGChzNlDBx0yezYzLlAFMaeRhES7 kk5V/etiCV9WxHiqY8GmnX8= X-Google-Smtp-Source: ABdhPJwZWXWUNVkgyYTtW0SFPElBeAGEfsA9TkWsRluzgsAtKHm13tPqN0cj0s/4D2Wt4UMZB1edbw== X-Received: by 2002:a17:90a:450c:: with SMTP id u12mr16772360pjg.93.1607765713923; Sat, 12 Dec 2020 01:35:13 -0800 (PST) Received: from syed ([106.202.80.219]) by smtp.gmail.com with ESMTPSA id s5sm13342405pfh.5.2020.12.12.01.35.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Dec 2020 01:35:13 -0800 (PST) Date: Sat, 12 Dec 2020 15:04:54 +0530 From: Syed Nayyar Waris To: linus.walleij@linaro.org, akpm@linux-foundation.org Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com, michal.simek@xilinx.com, arnd@arndb.de, rrichter@marvell.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, yamada.masahiro@socionext.com, rui.zhang@intel.com, daniel.lezcano@linaro.org, amit.kucheria@verdurent.com, linux-arch@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH v2 2/2] gpio: xilinx: Add extra check if sum of widths exceed 64 Message-ID: <7049b151670d3cb3ca190185bb484a79b2d5d845.1607765148.git.syednwaris@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.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 --- 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 05dae086c4d0..a2e92a1cf50b 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -340,6 +340,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; -- 2.29.0 From mboxrd@z Thu Jan 1 00:00:00 1970 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,URIBL_BLOCKED, 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 788A1C433FE for ; Sat, 12 Dec 2020 09:36:30 +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 E79EA23BDF for ; Sat, 12 Dec 2020 09:36:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E79EA23BDF 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=mP0p4ZfEIGVceobMsU2QEl3YRIm+dVnFHfz/Th/6Ehc=; b=UHsHnp36h1xYvs5J7IbvIuclU OCI+0FeyXB7n1vXPNHJC+1jQKIgf3ELzBZnwuchurO7z4Vb7tIGXDqKjlpw18LIiUNMVeGYmJ61Qw 9boOGIF9qon72jxqfo9WpNGRISvfasC1ItOkIs2LP574SmcM94VcUsM7CQrGbL48/dUqe7Iu1sx7A xkBTDCrfTSvUC+kxNH4cZ/pd/EPJXceiFyB/JKY6DeoQ1hZPbSDp3LHGK2ANg2ki6t2tDnCa6IwWu 3SFDrCmHQka84tG/R7F2QhWB71/slgut2SafCYdg2lj5IwIB9DFuZnZlgpBYNYXdFhsTBPvj0HO8v TKSKVlWOA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ko1J8-0002aj-0r; Sat, 12 Dec 2020 09:35:18 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ko1J5-0002aB-UY for linux-arm-kernel@lists.infradead.org; Sat, 12 Dec 2020 09:35:16 +0000 Received: by mail-pj1-x1042.google.com with SMTP id b5so3751407pjl.0 for ; Sat, 12 Dec 2020 01:35:15 -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=Yy8mAP2XRxcUpsdCsTm+KdTXMmpuQJot11SefIetIN0=; b=KVDtSO/0uKi/QiWrCU1zn8LcujpIvT+dkAK6HUZ93j38/Q+wLHDfplKTgdiVbzeMtl flByeS8IhAqGaM4xzRwM1ErjEBytK51Eg7hcFne7vL3kiWZmIyO/VkSa0yE+wUmO3MkY 2ItDX5YGfJy/zCkHG/K1SNWKWcXmkK5BKcaxahXVVDp3319WZrlDHTa7JcZ6RGEnDo9L 9KpEh5kKl8IsgVn++gvfaaAqXza+k2fziihzv68mnliqi6+CiuxyDxTLWh8bZelMx+Gf B4nt6ssW7RkPVJPXZbSRdJJKVmkaqHvOchQ0OstcveZPVYVbtQLpHlD3u/5ncYpbr69R TYDg== 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=Yy8mAP2XRxcUpsdCsTm+KdTXMmpuQJot11SefIetIN0=; b=Qz9wDXMz2uTvsq0OA1raO+d63d87IhPQl81v+Mu1U/mF3ukCphbXZx5BeNqA4g/QvY PT35kZ0s+RWrblOPnX1LJ/Gw/NsZ84yJvkTbot4Qk8jiaHdpGViP8FCNF4lhyAq4XLTs iRSPbLAIlgsBg1FSNFnkjKxP7RSuRVuQ/ba+qQRNB/Jo+82RLEpvA6VAxjAY8jBe7cnD sqbiKNCyGAue0b+cYBdD5Zlc4GpBM+RPlT6aYrf035ithde5sAoqkSjquyc1QetZTu6h pqltYJRY91UYOh6q33vjFo6oCU/VH6lJB+dDgb0ycjIJbCIzadw/HtQEdorivhxVkzvB 4lsA== X-Gm-Message-State: AOAM531BdtjpbKSAS/ihcZKn1auUUgaAlJajUe2k75nPpIhNh7icMGg8 +8NkAVycjGslEuT2JuB07J4= X-Google-Smtp-Source: ABdhPJwZWXWUNVkgyYTtW0SFPElBeAGEfsA9TkWsRluzgsAtKHm13tPqN0cj0s/4D2Wt4UMZB1edbw== X-Received: by 2002:a17:90a:450c:: with SMTP id u12mr16772360pjg.93.1607765713923; Sat, 12 Dec 2020 01:35:13 -0800 (PST) Received: from syed ([106.202.80.219]) by smtp.gmail.com with ESMTPSA id s5sm13342405pfh.5.2020.12.12.01.35.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Dec 2020 01:35:13 -0800 (PST) Date: Sat, 12 Dec 2020 15:04:54 +0530 From: Syed Nayyar Waris To: linus.walleij@linaro.org, akpm@linux-foundation.org Subject: [PATCH v2 2/2] gpio: xilinx: Add extra check if sum of widths exceed 64 Message-ID: <7049b151670d3cb3ca190185bb484a79b2d5d845.1607765148.git.syednwaris@gmail.com> 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-20201212_043516_024490_E807590A X-CRM114-Status: GOOD ( 14.18 ) 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, rui.zhang@intel.com, andriy.shevchenko@linux.intel.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 --- 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 05dae086c4d0..a2e92a1cf50b 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -340,6 +340,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; -- 2.29.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel