From patchwork Thu Nov 9 15:47:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: zangyangyang1 X-Patchwork-Id: 13451261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6DD05C4332F for ; Thu, 9 Nov 2023 15:49:24 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1r17HZ-0005M5-7F; Thu, 09 Nov 2023 15:49:23 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r17HW-0005Lm-Dj for linux-f2fs-devel@lists.sourceforge.net; Thu, 09 Nov 2023 15:49:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=plj85F9WLioXkxP9SfvyWC1tRgkaQ+khbwC9ufMW280=; b=WTxMYdWtoA8IW2ln4K9NJ48oPi 7SDxCJX9heQhuh3rN79BMo46UnI3S5j7E0JIAohDL5JtewHUZPoOTko37P8Dqe4fBUkN/B9Wwu1XV Q039UQzPtzhsvUQApZTamRcNDPb52gdqMafHqw2kC7bCqHaz6FImhXd5maSZ1amwAogE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=plj85F9WLioXkxP9SfvyWC1tRgkaQ+khbwC9ufMW280=; b=jmnu/1SmZ1WULhA/IJUKBW7vaD JtyYOILCax0Gzw15vUAaiMSBIc68gd3D+5/MvA168DDKRbhs6/T26qQa3+iW9hCfktQ+bIIAYWll7 8z2+QvG0cRVxxhA/RhrurklwpiWuNfQQ+mYj4F3WkV6W6RXCZX6kZDG6fjS7j2zrfjWU=; Received: from outboundhk.mxmail.xiaomi.com ([207.226.244.122]) by sfi-mx-1.v28.lw.sourceforge.com with esmtp (Exim 4.95) id 1r17HU-0018kq-CI for linux-f2fs-devel@lists.sourceforge.net; Thu, 09 Nov 2023 15:49:21 +0000 X-IronPort-AV: E=Sophos;i="6.03,289,1694707200"; d="scan'208";a="95922953" To: Date: Thu, 9 Nov 2023 23:47:42 +0800 Message-ID: <20231109154742.271947-1-zangyangyang1@xiaomi.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.237.8.21] X-ClientProxiedBy: BJ-MBX04.mioffice.cn (10.237.8.124) To BJ-MBX12.mioffice.cn (10.237.8.132) X-Headers-End: 1r17HU-0018kq-CI Subject: [f2fs-dev] [PATCH V2] libf2fs: Fix using uninitialized variables error in get_device_info() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: zangyangyang1 via Linux-f2fs-devel From: zangyangyang1 Reply-To: zangyangyang1 Cc: jaegeuk@kernel.org, zangyangyang1@xiaomi.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This issue comes from a static code scanning tool. When c.sparse_mode is 1, stat_buf will not be initialized, but it will be used next. If this issue does not require modification, please ignore this commit. Signed-off-by: zangyangyang1 Reviewed-by: Chao Yu --- Changes since v1: - Use calloc() instead of malloc() --- lib/libf2fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.40.1 #/******±¾Óʼþ¼°Æ丽¼þº¬ÓÐСÃ×¹«Ë¾µÄ±£ÃÜÐÅÏ¢£¬½öÏÞÓÚ·¢Ë͸øÉÏÃæµØÖ·ÖÐÁгöµÄ¸öÈË»òȺ×é¡£½ûÖ¹ÈκÎÆäËûÈËÒÔÈκÎÐÎʽʹÓ㨰üÀ¨µ«²»ÏÞÓÚÈ«²¿»ò²¿·ÖµØй¶¡¢¸´ÖÆ¡¢»òÉ¢·¢£©±¾ÓʼþÖеÄÐÅÏ¢¡£Èç¹ûÄú´íÊÕÁ˱¾Óʼþ£¬ÇëÄúÁ¢¼´µç»°»òÓʼþ֪ͨ·¢¼þÈ˲¢É¾³ý±¾Óʼþ£¡ This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/# diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 995e42d..47d4e49 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -931,7 +931,7 @@ int get_device_info(int i) } } - stat_buf = malloc(sizeof(struct stat)); + stat_buf = calloc(1, sizeof(struct stat)); ASSERT(stat_buf); if (!c.sparse_mode) {