From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 485391F7567; Tue, 3 Dec 2024 16:19:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733242766; cv=none; b=CZxKrnhfbzLqnzwtSopxhpbXxTRM2jULRH3lLKsmRPbh6OofKqe02WsfyN6OX8PuKjE/4CmSjx7OLPSDKQ5V24AjgOZZdYnfaP47E3fXF2Jh6uRGWGCTTrlPYCzyJ2B3qhS/EYfvM4BFROzNSUjP8+gIKn4CTW+Yr2MBGjUMHl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733242766; c=relaxed/simple; bh=mMFxzAZGKf87+0aALFVT1HkprTBzGZqJhKEzR57gH6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D++L1TZk10Hszsk2TpwMUD5n0F2W0qk+buROGXuKvrbK5TxGMTv/5zFlvOco5WIvURvvRGZ4AaJE5PRx2Onp8ZlsJAssbCTITBB0SQyDMSP28+UXySD5i6g07hsBOvlyzsbUwk4FpoMkT1k7cYd7FoBE2UBRK+bAF2EZoHW6PY8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=znMg5QCW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="znMg5QCW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACED2C4CECF; Tue, 3 Dec 2024 16:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733242766; bh=mMFxzAZGKf87+0aALFVT1HkprTBzGZqJhKEzR57gH6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=znMg5QCWd6ueGoPjAOekApQ2wEjYEHNQ6Ld1YROiUy83cCYF3bkcdg7xmqPgAeQMz ag56pEDxlN5DepfjEGPEDrS2/13MLS2efzjL7K094gUnhxbi7ZWdogqFEofHz6tyRr i74z6AxCTsvfCTdVam7ooxAArklnrgEg81BM2xGI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qingfang Deng , Zhihao Cheng , Richard Weinberger , Sasha Levin Subject: [PATCH 6.12 786/826] jffs2: fix use of uninitialized variable Date: Tue, 3 Dec 2024 15:48:33 +0100 Message-ID: <20241203144814.421146924@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241203144743.428732212@linuxfoundation.org> References: <20241203144743.428732212@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qingfang Deng [ Upstream commit 3ba44ee966bc3c41dd8a944f963466c8fcc60dc8 ] When building the kernel with -Wmaybe-uninitialized, the compiler reports this warning: In function 'jffs2_mark_erased_block', inlined from 'jffs2_erase_pending_blocks' at fs/jffs2/erase.c:116:4: fs/jffs2/erase.c:474:9: warning: 'bad_offset' may be used uninitialized [-Wmaybe-uninitialized] 474 | jffs2_erase_failed(c, jeb, bad_offset); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/jffs2/erase.c: In function 'jffs2_erase_pending_blocks': fs/jffs2/erase.c:402:18: note: 'bad_offset' was declared here 402 | uint32_t bad_offset; | ^~~~~~~~~~ When mtd->point() is used, jffs2_erase_pending_blocks can return -EIO without initializing bad_offset, which is later used at the filebad label in jffs2_mark_erased_block. Fix it by initializing this variable. Fixes: 8a0f572397ca ("[JFFS2] Return values of jffs2_block_check_erase error paths") Signed-off-by: Qingfang Deng Reviewed-by: Zhihao Cheng Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- fs/jffs2/erase.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c index acd32f05b5198..ef3a1e1b6cb06 100644 --- a/fs/jffs2/erase.c +++ b/fs/jffs2/erase.c @@ -338,10 +338,9 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl } while(--retlen); mtd_unpoint(c->mtd, jeb->offset, c->sector_size); if (retlen) { - pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08tx\n", - *wordebuf, - jeb->offset + - c->sector_size-retlen * sizeof(*wordebuf)); + *bad_offset = jeb->offset + c->sector_size - retlen * sizeof(*wordebuf); + pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08x\n", + *wordebuf, *bad_offset); return -EIO; } return 0; -- 2.43.0