Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp292272pxu; Wed, 2 Dec 2020 23:34:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjyxtrzIQjYG9gVgFjG+w5pPPIYnNmUzhzF3LxPaUhNVVwpp22C1+2LCTwHkkoe2i3VGT7 X-Received: by 2002:a17:906:7f11:: with SMTP id d17mr1379564ejr.534.1606980847729; Wed, 02 Dec 2020 23:34:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606980847; cv=none; d=google.com; s=arc-20160816; b=aNtGlECGqaqxMktrYlpC3P1qsLUXDCLWaSVnmKPAjV5v7x22kKG96IBkWNWdeAphQA eOGyk+wvnQuZ+LT3SqGojirTH7cj75QXcVPpkAnIPD1MudS3Thv4Kmr4BEV/YGkOTyIM aBmKJZoZVpsGXvvp7T/xO27+qj1ypWDGzc3gSrihKasrDJkmdFVHzVp7NlC7lh77p1rk pNH6Up6qyst2Tq/SumGlWMm+BtbdmuW6oT/uFkDqHVJFqTt+7wxqegMZU05yHsCgB3eP mXq2YOn6ECVLuhyPwuPw2rTkRqVdU42wXCwyaJaeYVKA8wao7tw274ecrYvjIN3+9ZUm /+Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=6WyxoXd8rBKCoB1roUtq3NDcR4MoW3oymRAHnzWgpfU=; b=C2IwoJKlPMX0183lcTnqvE1DgE/+PfbVbLnffHtcDIJQ9MHl8U/cDz/UKa+SzrfAYX Z9OP4EKhtKALPNWjsmlqmVA8prsC4hi7yg1gN1DedcsXgGc17EN0A0VMyhC6ftPCdl6w 5EcE9pGb5mKklBrGnH9YLF4vN5PixfxxWlGT22AkGh1ifoEw0/iQUs4rgiE+tPUUc3Vv iKwM/O9znJLpnltfPryHZsa1TzR3V37Zwvt9lVGLBE1/ASWATbXkQM2gVcIRy0mLNf17 fB/GO52Yev+Gt+ExbxYKXNcUhqgldSWqxZO+3/r2KwajjbSMleDoKwlHWv3hpJMepDzK sjyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si610231eji.735.2020.12.02.23.33.44; Wed, 02 Dec 2020 23:34:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387478AbgLCHcA (ORCPT + 99 others); Thu, 3 Dec 2020 02:32:00 -0500 Received: from inva021.nxp.com ([92.121.34.21]:57696 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgLCHcA (ORCPT ); Thu, 3 Dec 2020 02:32:00 -0500 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D69FD2017BA; Thu, 3 Dec 2020 08:31:13 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D00EB2017B6; Thu, 3 Dec 2020 08:31:10 +0100 (CET) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 5B0D5402C4; Thu, 3 Dec 2020 08:31:06 +0100 (CET) From: Biwen Li To: leoyang.li@nxp.com, bgolaszewski@baylibre.com, aisheng.dong@nxp.com Cc: linux-kernel@vger.kernel.org, jiafei.pan@nxp.com, linux-gpio@vger.kernel.org, Biwen Li Subject: [PATCH] gpio: mpc8xxx: resolve coverity warnings Date: Thu, 3 Dec 2020 15:39:10 +0800 Message-Id: <20201203073910.20113-1-biwen.li@oss.nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Biwen Li Resolve coverity warnings as follows, cond_at_most: Checking gpio >= 28U implies that gpio may be up to 27 on the false branch. overrun-call: Overrunning callees array of size 3 by passing argument gpio (which evaluates to 27) in call to *mpc8xxx_gc->direction_output cond_at_least: Checking gpio <= 3U implies that gpio is at least 4 on the false branch. overrun-call: Overrunning callee's array of size 3 by passing argument gpio (which evaluates to 4) in call to *mpc8xxx_gc->direction_output Signed-off-by: Biwen Li --- drivers/gpio/gpio-mpc8xxx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index a6c2bbdcaa10..12c9a91d87b7 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c @@ -3,6 +3,7 @@ * * Copyright (C) 2008 Peter Korsgaard * Copyright (C) 2016 Freescale Semiconductor Inc. + * Copyright 2020 NXP * * This file is licensed under the terms of the GNU General Public License * version 2. This program is licensed "as is" without any warranty of any @@ -80,7 +81,7 @@ static int mpc5121_gpio_dir_out(struct gpio_chip *gc, { struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); /* GPIO 28..31 are input only on MPC5121 */ - if (gpio >= 28) + if (gpio >= 28U) return -EINVAL; return mpc8xxx_gc->direction_output(gc, gpio, val); @@ -91,7 +92,7 @@ static int mpc5125_gpio_dir_out(struct gpio_chip *gc, { struct mpc8xxx_gpio_chip *mpc8xxx_gc = gpiochip_get_data(gc); /* GPIO 0..3 are input only on MPC5125 */ - if (gpio <= 3) + if (gpio <= 3U) return -EINVAL; return mpc8xxx_gc->direction_output(gc, gpio, val); -- 2.17.1