Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp584800ybh; Tue, 21 Jul 2020 02:56:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbhZWZA3KwP1kDd3TX1i3lhYhfsICizMbaDcFZyfR1qCzx5/OX3d0+kOzSjD2PTg0NxbFy X-Received: by 2002:a17:906:280c:: with SMTP id r12mr21863828ejc.105.1595325371354; Tue, 21 Jul 2020 02:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595325371; cv=none; d=google.com; s=arc-20160816; b=D8JMI7pR84hav+DI43kLk2WWhm5LRGDa6+CVpcWKn7/5e8fj5zzyT2sc9Lk7y2H/m6 gagWZgUUixNLEDvKU95bb49MvyUuDGVzZ6uYuhcxgRAJmA8Zo2J0JFkAp1rCRoXvdHxt UrqgmBqGgaAyOY2Fvuy05m8gKKEQt0YXUR+lo526vON7Qr+enjPBHIZWcbhCxw7qKXjZ vBZhPfI92l0s+fb8mgx+KTzGBmUWjjWiaWPbYPRw2FXAY4sALI1g1utJgICyQujn4XsT wwTkBY6f8tVZCX15AivJ33qA/8pd3v0YFdgYGt3pLdKvFSU+2B0uLde/N+Yn7rg5Vzf+ 0K2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=icEBuIRIzSKP//8c/7EqBnZJg430yOMrOqQUZ4Zi+tI=; b=iBCeKcjdWUpbPQwOqNXj/ZADzRhppZT1+I52NsH8l0LgwtfukC4TqeMFOe8QYnnsy6 kyx17jGR83DHAzbXXZDcpWlpeS50zT+mhr/QQa5syisMzBosQK0KmKoRB76BIgBRvcq0 Be2X3XazFj/mFJd7eGOD+ODR4hYZ3Eka2sU58ghy7aJ1/yvjxeCzEANHRd9t2T0BsWO/ SIdo1dJKFEdvwG4EZ3N7CtMlfJPtuNHCc9b1Ik+zJoAc519dc9HfmS21M1lfJ3EkQxqJ laBfspd+e75uhGwa4afmfR5MwCS7FKtm42ehYwB/zIC26R0BYQluXgOL+OmBMfLtcFIc 10NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b="R/6Pr5DC"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr16si11275307ejc.502.2020.07.21.02.55.48; Tue, 21 Jul 2020 02:56:11 -0700 (PDT) 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=@st.com header.s=STMicroelectronics header.b="R/6Pr5DC"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726458AbgGUJxZ (ORCPT + 99 others); Tue, 21 Jul 2020 05:53:25 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:1876 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgGUJxY (ORCPT ); Tue, 21 Jul 2020 05:53:24 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06L9hPV1013177; Tue, 21 Jul 2020 11:53:02 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=STMicroelectronics; bh=icEBuIRIzSKP//8c/7EqBnZJg430yOMrOqQUZ4Zi+tI=; b=R/6Pr5DCIJWS44LbTl2KDBXcuGjkaJYwVCI/3XQSnNQMlrU023HQblkPg7zl8LfZY6Vf ioQwE/R8zrTIX+atGcNzWG6A0bZK2ZTJyLeEDcUpxSRgRhBmV3rDX2HpcnlUJh0r8PVk ljTZmvWt8L5ON673WOYoUHEfrJW8kRakRvK8NyJFcAncDh1xZxJa2hOjy1Ses8QKo9R2 iF5c4BrbNGHhCHiOvbTAuOdbrIXB5QDFfK/VhHggit1X5ItZH5mLEZejDYb43sgjK69g dczFV6zUGt+fDlO0ZTpNcsK2/UDJvn14j8dM+fD+BHTqxGkFd+sEOrLlBaJK2N/wHJpz TQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32bsfpd300-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Jul 2020 11:53:02 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C6BD710003A; Tue, 21 Jul 2020 11:53:01 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag6node1.st.com [10.75.127.16]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id AC1A12AD9F8; Tue, 21 Jul 2020 11:53:01 +0200 (CEST) Received: from localhost (10.75.127.48) by SFHDAG6NODE1.st.com (10.75.127.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 21 Jul 2020 11:53:01 +0200 From: Christophe Kerello To: , , CC: , , , , Christophe Kerello Subject: [PATCH] mtd: rawnand: stm32_fmc2: fix a buffer overflow Date: Tue, 21 Jul 2020 11:52:07 +0200 Message-ID: <1595325127-32693-1-git-send-email-christophe.kerello@st.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG8NODE3.st.com (10.75.127.24) To SFHDAG6NODE1.st.com (10.75.127.16) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-21_02:2020-07-21,2020-07-21 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch solves following static checker warning: drivers/mtd/nand/raw/stm32_fmc2_nand.c:350 stm32_fmc2_nfc_select_chip() error: buffer overflow 'nfc->data_phys_addr' 2 <= 2 The CS value can only be 0 or 1. Signed-off-by: Christophe Kerello Fixes: 2cd457f328c1 ("mtd: rawnand: stm32_fmc2: add STM32 FMC2 NAND flash controller driver") --- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c index a4140af..74fecde 100644 --- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c +++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c @@ -1791,7 +1791,7 @@ static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc *nfc, return ret; } - if (cs > FMC2_MAX_CE) { + if (cs >= FMC2_MAX_CE) { dev_err(nfc->dev, "invalid reg value: %d\n", cs); return -EINVAL; } -- 1.9.1