Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp314207pxu; Thu, 3 Dec 2020 00:24:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGsr1kzNz1AdaVBQBWoSM6bX4ys7Qgsuy2IgOsEtQ/AuQk9Yf7oRT5SmRPIJTudA8t1mwe X-Received: by 2002:a17:906:3712:: with SMTP id d18mr1544109ejc.178.1606983871835; Thu, 03 Dec 2020 00:24:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606983871; cv=none; d=google.com; s=arc-20160816; b=U98x224bmEIc8isTMiEXpROlrtHLQsCJF3mpWO+b6kJyAtLWoxUmN9oJWiK6m5buGV OTPWThj3pPKtjdAzc3CmD6VDS953JbfyxnVwcCtnaOfc99WKqS8ms+RxJl2ra5kk1I1y 4YY9m1Ll/mdYI/eNLhO60IG8kbPOvtl5fyWikMljvC8aIlQ1n4zXpLk/0HV5TrXuLkLU AJBbVK2h+a//oMyLxgCe5W6EHvvh8cEI/ivUWsHJglDIWSMYdf7JjAar8yPR5jqjP2mN rp0hDTukDXywnukE4VO7/Gc5Pl89FmiQPfT6eXh4L+J5FbL2ii2zWPoQL92Vq+mOScJ4 UIbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MFI8X7LTPxfxGnHVnTh7HU5fhkIJdGHe319oXUiaOMg=; b=pCf3Mz80d/exvmtyBjhvPyY26gvPwQTip9qSB7K911nPp3x7OjTHz6n21XFSfzXMjC DJt2lWBvrWdLM63vIDfXT0QuR/pg60woSU2SYvrISbimpuDc1NwzfvdJBIGHpmuiHT0L chAECbMcmdmgTSx8j1u8f0xVbI46shaLqlw6t84Zk9c/sBg1yh/5UE3Qkno5COXqVOYZ rkyL1al5cHtpFn01416smGojo0kOlv6OxKV1Sr5+s8UldygSl0q9YK6YtoKewW09BVbH O7WF5Ls/oJ+0PUkncTR+bZdqEqTZ8aZ0kO7ZII/tLz2ghrYdph2D6aCZ5YK6xnrQ+D0X FCSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=hxDEkT+C; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o14si659496ejm.610.2020.12.03.00.24.09; Thu, 03 Dec 2020 00:24:31 -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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=hxDEkT+C; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388348AbgLCITo (ORCPT + 99 others); Thu, 3 Dec 2020 03:19:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388341AbgLCITo (ORCPT ); Thu, 3 Dec 2020 03:19:44 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E233C061A4F for ; Thu, 3 Dec 2020 00:18:58 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id v22so1119840edt.9 for ; Thu, 03 Dec 2020 00:18:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MFI8X7LTPxfxGnHVnTh7HU5fhkIJdGHe319oXUiaOMg=; b=hxDEkT+CnPTTluKPdfjsvD7vZ5oEtmAvD59tEncI4rMof+lmV243KDQUpBZ+usebfw PgU1bzfy6bWjMDkq53fYjWsaFfah2AzdvmaGvmeWbOo1AsAbtjbebZzysqBFPlpxjvr/ Q2IyiKX7/OPD1MzchSNkBrRZne+5aXnTOWl22SBUqUGYUEOHhFJ3rPDEQ/bHq/q4YwNX VkbqRrLkaxkoan/8i1lQuJJdFT/uvJPgeW5nYTPe6+NJekju042FHliduluGyxIuFIrR 0Op0jpddYUQ6ExmXHzFHQLkhDnVwShiMdIqYR2TrKnFmjMchB/Kqb+PV7/SdYAMS/Urr ouzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MFI8X7LTPxfxGnHVnTh7HU5fhkIJdGHe319oXUiaOMg=; b=fqkqtIy7qaaFAd0TAiTp1xO3nIeDClEE9sWu2G1yW+3UJ46NhCmOUjzlJITxy3fzb3 K3I+Ly5LLNd6s0DprKLV4S9T7Q2lWsi1LBaUzgtvaM3sKqR0eajwhdjaqO7G/qF6njE/ cEnSy8ZyP36x67sTTTRU7nGVmm9jV6M6dlLAbqvmgNmYi9LUCNuBH78SDNN1I410tYjO 9jFSSeW9NbwoFRZvxBZRUUnM3GE1o6+G8dOEisExOs0ZLKIqrGKbJOw4Ty/rXy0H2ks6 F0IrpL3KuMoAUt8I3bp0YjfSTnSollySnm/XCYA4jArf3xaNwxdzF5GRMhiVttedqVaa zXsA== X-Gm-Message-State: AOAM532nH8RucCldhOZjQE1OfLK/mbrGsADJ9fQVjKULIpV+omdwKjIu aG+VP6antjwrQTnURHJZeCzxN2dKqk5u89fyXmRcTA== X-Received: by 2002:a05:6402:16c8:: with SMTP id r8mr1744893edx.59.1606983536735; Thu, 03 Dec 2020 00:18:56 -0800 (PST) MIME-Version: 1.0 References: <20201203073910.20113-1-biwen.li@oss.nxp.com> In-Reply-To: From: Bartosz Golaszewski Date: Thu, 3 Dec 2020 09:18:46 +0100 Message-ID: Subject: Re: [PATCH] gpio: mpc8xxx: resolve coverity warnings To: "Biwen Li (OSS)" Cc: Leo Li , Aisheng Dong , LKML , Jiafei Pan , linux-gpio Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 3, 2020 at 9:07 AM Biwen Li (OSS) wrote: > > > On Thu, Dec 3, 2020 at 8:31 AM Biwen Li wrote: > > > > > > 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 > > > > A copyright notice on a two-line change is a bit too much, don't you think? > Okay, got it. Will remove it in v2. > > > > > * > > > * 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; > > > > I don't really understand the commit message but looking at the code is even > > more confusing. What are you fixing here actually? > Try to fix code warning that generated by coverity scan tool(static code analysis tool) Please explain what benefit there is to using 28U over 28. No tool is perfect, that's why you should try to understand what it is it's trying to fix. I don't see any reason this code could fail. Bartosz > > > > Bartosz > > > > > > > > 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 > > >