From patchwork Tue Jun 15 14:06:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 1492351 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=IFDs+M4I; dkim-atps=neutral Received: from bombadil.infradead.org (unknown [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G4DGm24Nhz9sW6 for ; Wed, 16 Jun 2021 02:26:40 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+FJTuFr5ilxYtFacAZIWVYjnAREBAdI7HDcijkwHN/8=; b=IFDs+M4IBJS8qL /OztKe0mqBzVPxKCkA7fib01dieoootwvRDdQ8PPJ6xoGW053wlXnvo1B6HkPGkd66mV8pTrEGs3f jnxZ3lDRaMGPjmxwbGGCn8z0sWXVSrhoovdNp5GLejJ1nZGmxjNjCp9FKXGT3QMJ4CUdiCbvTz7/4 jHiqAC8dOenTG93ZQrpqGyFHJ1E/U5CFBtCq41EZhtPjEd644IDAWJ0qTzdWWa76OBpibdDau5DdP 0oB4qvN4TYJGpNuVQGsWWvqoEESgHf848Vq55mdG9vU3XBcEWm87i25nVqr9IjWnRG4rnz/sW3unk T40UkTap0EswezJ01GNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltBr1-001KS3-I7; Tue, 15 Jun 2021 16:23:55 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt9ip-000SAI-JE for linux-mtd@lists.infradead.org; Tue, 15 Jun 2021 14:07:21 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lt9iO-00029g-Sq; Tue, 15 Jun 2021 14:06:52 +0000 From: Colin King To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Heiko Schocher , linux-mtd@lists.infradead.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] mtd: devices: mchp48l640: Fix return of uninitialized value in ret Date: Tue, 15 Jun 2021 15:06:52 +0100 Message-Id: <20210615140652.59521-1-colin.king@canonical.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210615_070719_730055_B7935A9A X-CRM114-Status: GOOD ( 12.51 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Colin Ian King In the case where the read or write lengths are zero bytes the return value in variable ret has not been initialized and a garbage value is returned. Fix this by initializing ret to zero. Content analysis details: (-5.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [91.189.89.112 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [91.189.89.112 listed in wl.mailspike.net] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Colin Ian King In the case where the read or write lengths are zero bytes the return value in variable ret has not been initialized and a garbage value is returned. Fix this by initializing ret to zero. Addresses-Coverity: ("Uninitialized scalar variable") Fixes: 88d125026753 ("mtd: devices: add support for microchip 48l640 EERAM") Signed-off-by: Colin Ian King Reviewed-by: Heiko Schocher --- drivers/mtd/devices/mchp48l640.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/devices/mchp48l640.c b/drivers/mtd/devices/mchp48l640.c index efc2003bd13a..0833f41e9d17 100644 --- a/drivers/mtd/devices/mchp48l640.c +++ b/drivers/mtd/devices/mchp48l640.c @@ -210,7 +210,7 @@ static int mchp48l640_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const unsigned char *buf) { struct mchp48l640_flash *flash = to_mchp48l640_flash(mtd); - int ret; + int ret = 0; size_t wlen = 0; loff_t woff = to; size_t ws; @@ -267,7 +267,7 @@ static int mchp48l640_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, unsigned char *buf) { struct mchp48l640_flash *flash = to_mchp48l640_flash(mtd); - int ret; + int ret = 0; size_t wlen = 0; loff_t woff = from; size_t ws;