From patchwork Thu Nov 9 13:00:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: zangyangyang1 X-Patchwork-Id: 13451033 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 2FB3EC4332F for ; Thu, 9 Nov 2023 13:17:04 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1r14u5-0006t0-8b; Thu, 09 Nov 2023 13:17:01 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r14u4-0006su-8c for linux-f2fs-devel@lists.sourceforge.net; Thu, 09 Nov 2023 13:17:00 +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=TrrbdLOnk3eXTb55n+vwXi5z5c LH0/TaAhFuR432QL3K39Y19cdo3U4hci6MyWqvszFq9I9A6RUWy2Tmqki0uxOyLjqVJABuI2azep+ EScal4hPY9aufySvcTAZf4v1BDcl9u8tP8higxhtcS4wAtDmnIQicGXH6FkPDt1ZpJbo=; 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=goOJkUouhgLM8B+gPMZX7RlrIB UyZoJulndiv6bPswTeWFMGy/WmKbx/jEO9bVV6vf6eTqQZJSlatcCb8S+MI0QcMABtaWW34SZNOeS 9B+22NmvqdyXQFHXOzj2CVT95QYddhBOT1IEdoxbjYGHeCwsrP66pP74Tc6fgDiAoljQ=; Received: from outboundhk.mxmail.xiaomi.com ([118.143.206.90]) by sfi-mx-1.v28.lw.sourceforge.com with esmtp (Exim 4.95) id 1r14tz-000pKm-Ux for linux-f2fs-devel@lists.sourceforge.net; Thu, 09 Nov 2023 13:17:00 +0000 X-IronPort-AV: E=Sophos;i="6.03,289,1694707200"; d="scan'208";a="70295410" To: Date: Thu, 9 Nov 2023 21:00:04 +0800 Message-ID: <20231109130004.261931-1-zangyangyang1@xiaomi.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523122720.1628122-1-zangyangyang1@xiaomi.com> References: <20230523122720.1628122-1-zangyangyang1@xiaomi.com> MIME-Version: 1.0 X-Originating-IP: [10.237.8.18] X-ClientProxiedBy: BJ-MBX14.mioffice.cn (10.237.8.134) To BJ-MBX12.mioffice.cn (10.237.8.132) X-Headers-End: 1r14tz-000pKm-Ux 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: zangyangyang1@xiaomi.com, jaegeuk@kernel.org 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 --- 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) {