From patchwork Thu May 4 14:37:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13231271 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98099C77B7C for ; Thu, 4 May 2023 14:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230193AbjEDOhV (ORCPT ); Thu, 4 May 2023 10:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbjEDOhU (ORCPT ); Thu, 4 May 2023 10:37:20 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE1F5ED for ; Thu, 4 May 2023 07:37:18 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 344DTc98005255 for ; Thu, 4 May 2023 14:37:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=corp-2023-03-30; bh=7QXqzv1aQWQuCXzXybYT1nmIM1bL5IVdsEaHx3Iuyuo=; b=tFRJIDKQdPQU8d3+ysByz0aDCsNnauxKKo3V/jOSIOO2b8DhLnmfInlWFOjBrW7zTM1Y FZdxyc2j/fcIN+D+IuoHHmlQXQOpM/gODojhyzoPTrYNdKN+zHBVt5GRxHKO+4BHRNcU JQgo1KsQtPxlWgc4CSX0KHckgsugW7vVTxesoizymSKp/atswal6fPDwJOxoYiPJVRl5 HkoW4WsHDFvsRISDYMW4cTaUDMKp/+MdvtFuljCtnLMdnzIoUoyfhoi6sPL+yue37kXm YgO7sZRP7lDD1djJzYvOa34ywiuCkM9kHjMasSP9rgeYs/Jxj9OV6cd7jdkjdu8XtlP8 7A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3q8su1t0k2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 04 May 2023 14:37:18 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 344EIDCQ025048 for ; Thu, 4 May 2023 14:37:17 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3q8sp8t6jy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 04 May 2023 14:37:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wz4XylDk9ZMdzgYzKE9pcO9zop6VVmuKSr7cqr93pNpobkX5r5or0Dux0yzbUo3Vx4EZUweA7yr3BkrkNuOxI50YCa4oNK6yFbDPh+mO54pO1QlaCtetX5jEFx4jpp5jSQzCrYwNZWfZnVBb4uicTFGfdPdZWrQT23ztJ2DUV7HKxDgdAUX51SS1Anvz9a4UvbzmewDEqCFr36CqtsxRYV6u/KlJv1vFzSXzb7CRGK0z5o6guMzkIaQbBFmEtIS6q8F5nV6qXhcBMZE21OlDcue9gI1y3w+8ugny8gwazlABMb1c9JSaNjeEuMZ4tuKI0tTMSjJYhbZ/1rFqTBndMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7QXqzv1aQWQuCXzXybYT1nmIM1bL5IVdsEaHx3Iuyuo=; b=M856Bky7rjZx54k+sFyae2cc7zK1oG+cQx9b+hZJ/o7LBk/iSWf0m14OnlADLuJE85TCckiDbGPkUW8Wv4NH004JVKGBM0KoW5FX4UMJItyUAdFsi51RevV7JPNP7ZCU6WTdtIhcSCcJPFQyuhykVyDUgWeNPmJj4msA2WSvSpIeF/lTXFSFsL1iMxcavbfbeju3JhNw8m/Ve4TCTaIdzj4VplcarqrKDiw2aXIU+f6QefWOyESPxVZ1iKbyPgxF3ffeWGbJnQYxZjRWrzLwY1FJzYq6UlraCJn4m8Y3ZTs7QTqhg/VbSXr9MIE2uuQYjMFSUn8Qh98JKxpDmjW1UA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7QXqzv1aQWQuCXzXybYT1nmIM1bL5IVdsEaHx3Iuyuo=; b=ujwUWsxxibrX/MkbpLKgJSkl8xjdzfdPGsGl/xc6CP7XJNhmCIj+qLND/loQCy6kxMRNIClVwBkH7/ny5so/klG5a5/kkKFmCYVLWOjgfl1R4xpOPuEZNSQYPNZ+/OciB4LQ93cnnLiZeg8bDDMIgyVjzN11gr4bGUp976k8Ae4= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DS7PR10MB5312.namprd10.prod.outlook.com (2603:10b6:5:3a9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26; Thu, 4 May 2023 14:37:15 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::bc67:ac75:2c91:757e]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::bc67:ac75:2c91:757e%7]) with mapi id 15.20.6363.026; Thu, 4 May 2023 14:37:15 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: fix may be used uninitialized in __set_extent_bit Date: Thu, 4 May 2023 22:37:08 +0800 Message-Id: <377fe88656a9ebaa34e60debc5ae80638e277076.1683210012.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 X-ClientProxiedBy: SG2PR01CA0169.apcprd01.prod.exchangelabs.com (2603:1096:4:28::25) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DS7PR10MB5312:EE_ X-MS-Office365-Filtering-Correlation-Id: ea819cb7-82e6-4a53-bbdf-08db4cad0e07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fwMlUKWl2P0skZleDTri/n6qdU+TJBaIKDEtuT4JT7B4Kk1fKhA3FB0EgFyirvd8xnJgBLsDoLotWuIy+8PWsnYTph1Kn6BVmUhjeWyO6NbBr5+WkCgjr3g0VsSPwcT7ccY1CIRxW9R9PPh3vKcUNlJX7KTuwA8mlkmThqi3W/iMEogOEt8UiIx13YuMO7ZZv0lgb+dj3cgm7N1F9E5Q3bwz+S4jYfdRoLPykrzbPsrR/3jFWSp/2PQGrlZFA4IHp4VZyVUDwqprLQ9B9PXldhIuexNUnJo4E03Vcb/qecitmgMa55cA9a/aicVXO9sRSrjgnt8k7BvCBsV/7Zt7D3WKUoDiFgGUkrCph8GdsmFfnuuD3Yc6K2HQeGbyo6IFCiSutsThqs4MV+71H6I98OGzaOzyfgAXYBtXFROnJThRwPV//gMv45JBzKxWMWO8WiksCHHk0f4Qe1mAjXdit04GzqcSwJWIzqPkPj8cRAjikj1sy2rzREigfXioMTZWHbAUjdegUhtbUtn6AqaEEFXWXEf538ETgYEUEerTucVSEAZmtayH5HWWzPkFLnJ9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(396003)(366004)(39860400002)(376002)(346002)(451199021)(83380400001)(5660300002)(2906002)(66946007)(38100700002)(186003)(316002)(8676002)(8936002)(6512007)(6506007)(41300700001)(2616005)(6486002)(36756003)(66556008)(66476007)(44832011)(6916009)(478600001)(6666004)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?NJlEdmIFBLUhdtTesRIOW1sNg/s9?= =?utf-8?q?Td01im2Go1+sQmLzhU6LuvvYKR+EknffLIgSSvajcYzze43h3I0NlOlz89ahtVpzt?= =?utf-8?q?TbPbCRN1Q5asGTyFaI/GQmIZxO89Ay5nuKzjikIBVYc6xQ/CAq5g06X/Qy8wV1LSr?= =?utf-8?q?qGXcCfzV16HgV3nLZzHd3GF1LBR1pQ1ya3mH74ojB00qWU5aNZc1kdHPB24Kdfe6D?= =?utf-8?q?V4P+XrQOjrc6NoOqsfI+8hivU+BNvOVgAw6dBndkK73omKtf1HicA0iHMR6ENUpnl?= =?utf-8?q?dTQCjpZt6l1/vJJghZfsx6T06HmVpa7uMJYuVZzDfPWef3tRra7QyIAiG4j4QKxBC?= =?utf-8?q?aoiw9J02Oyx3QhOeWVUkoBGWXyDYP2toeczq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mf4wE8atAWLGjRc2vBOFQRKz+h6PONRBtIhDpZ/KOjiJ4xCjZJZ3rBhCAK1n002YTMUf5+wW0qDXRoRZWQXlJ+wTe0LySPMOSBq68ed3RTTy0/Ue8jSEL9tQnVQf88qah3wkOy5D4v7adB4qY7koTJmQPOn9RUxsIpE3GDtk8bgzKLta3AQ1SKSLIcTWe73llbtU X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea819cb7-82e6-4a53-bbdf-08db4cad0e07 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 14:37:15.3399 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: n7scBcbTTIOI2KRNP6XPZVYGoW26+/A5EebWlseMOsRE5hSjc118w52mL1WhEGP+bhnKbGbW6ZcDpXiiUF5IUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5312 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-04_10,2023-05-04_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 phishscore=0 adultscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305040119 X-Proofpoint-GUID: 6W2uJCoBzTtfwFoBE6EVqrQTrUZxwruD X-Proofpoint-ORIG-GUID: 6W2uJCoBzTtfwFoBE6EVqrQTrUZxwruD Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Compiler is throwing out this false positive warning in the following function flow. Apparently, %parent and %p are initialized in tree_search_for_insert(). __set_extent_bit() state = tree_search_for_insert(tree, start, &p, &parent); insert_state_fast(tree, prealloc, p, parent, bits, changeset); rb_link_node(&state->rb_node, parent, node); Compile warnings: In file included from ./common/extent-cache.h:23, from kernel-shared/ctree.h:26, from kernel-shared/extent-io-tree.c:4: kernel-shared/extent-io-tree.c: In function ‘__set_extent_bit’: ./kernel-lib/rbtree.h:80:28: warning: ‘parent’ may be used uninitialized in this function [-Wmaybe-uninitialized] node->__rb_parent_color = (unsigned long)parent; ^~~~~~~~~~~~~~~~~~~~~ kernel-shared/extent-io-tree.c:996:18: note: ‘parent’ was declared here struct rb_node *parent; ^~~~~~ In file included from ./common/extent-cache.h:23, from kernel-shared/ctree.h:26, from kernel-shared/extent-io-tree.c:4: ./kernel-lib/rbtree.h:83:11: warning: ‘p’ may be used uninitialized in this function [-Wmaybe-uninitialized] *rb_link = node; ~~~~~~~~~^~~~~~ kernel-shared/extent-io-tree.c:995:19: note: ‘p’ was declared here struct rb_node **p; Fix: Initialize to NULL, as in the kernel. Signed-off-by: Anand Jain --- kernel-shared/extent-io-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel-shared/extent-io-tree.c b/kernel-shared/extent-io-tree.c index 206d154f09fa..35e21feed4cd 100644 --- a/kernel-shared/extent-io-tree.c +++ b/kernel-shared/extent-io-tree.c @@ -992,8 +992,8 @@ static int __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, { struct extent_state *state; struct extent_state *prealloc = NULL; - struct rb_node **p; - struct rb_node *parent; + struct rb_node **p = NULL; + struct rb_node *parent = NULL; int err = 0; u64 last_start; u64 last_end;