Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1395402pxb; Sun, 12 Sep 2021 18:02:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBiwi0CD5sxYqbTRyIJmdD7qq/3m33gFJYB3inJ8CoGEdLR5xXobu8MvlioNC1E4w/KTpJ X-Received: by 2002:a17:906:9aca:: with SMTP id ah10mr2634195ejc.471.1631494943821; Sun, 12 Sep 2021 18:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631494943; cv=none; d=google.com; s=arc-20160816; b=0XmPyzcS9rJTHyVF/LfnzGz8k8/z9axKsO5j1ac+/5Kd47dJ6UBWRmzSJJIRK/dUqe Sx1CF8ddbzxAfjfDALYh5g81dHUleQAymaZcwdlxQjXW87k65TdXdGJlC9Sh8rmJtWZl dk5+K9N2AVtv7S8YSI1rr4T24nVfnDXNkEReJy168D+lNotsD50SxE++j+eMjGJJ76Ip saRlbmQRTTqIWKmu0b9H+8cbBw1sIdjCBGGO8wLXemvMuYyu1MPeHg948YydZNZhWS/n RUzoQWC9o9p68C/7mPWoiJgRUf9/kHRjWKgcrSGJMXaAsXCZJYElOzMTJ0ptQdq1uo9h MAQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=00EBdw0F78i8nd+9LQNexWyftZYJIY2dUDi+gKaiaM8=; b=nAjzOyOl86sE/6ypp23VsEmNYOEG0NCQxOxNcgeiloo57X2ssZzQMZ1Q96+jDSq0YZ fc0icdsGBVmAdiC5bFspSADfysnTpPZj6fJQs2iKDd/qek+k1VZrBzE8MYYkKqe8zPFM OVUPfOHs0A564GudjeMT4MFiPrqHkL55PUEFWuV9zNVXDl0bnEpMtkrnMszv+6WvkYr6 mno2VDhN61xlJUpGpABVopPJbekvuHEaXURd4BZZKAia4baahXyLDYHPLhIcpJH0jnZr +fI1lE2r6ON3U+fTKy7LCjv8R0OVosaKGzGDwd0G52HSGLNIAPU2MjXtkBQM2iPJcgMA akPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DKsaiJIr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id og48si5536694ejc.686.2021.09.12.18.01.32; Sun, 12 Sep 2021 18:02:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DKsaiJIr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236633AbhIMA6D (ORCPT + 99 others); Sun, 12 Sep 2021 20:58:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:44002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233133AbhIMA6C (ORCPT ); Sun, 12 Sep 2021 20:58:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0672160D42; Mon, 13 Sep 2021 00:56:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631494607; bh=SBe2GPgrtzIMcpZywnsegClabFSYgEfpXE7JVxZobiU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DKsaiJIrVUd/I34h9uK1tpZNYt2hCCBd8nCC9kb4mCAG98SgN7k1TuqZ16PQdfg6x S64fQsivYnL/cvNCB4stBB+wT9bWkRjwumny8xaoTDENEA9Sia98BG0t0a4s4H4K9f 8ZeBpUVloropxOXz7XJT9Wy8+ZKJQdGTuOSxk7NkHv06wYrgiQDEpp3NhEZNlT1sdM rKFxU4m9KGKIcnoYKKUWKF5Aw8liYJk5pvlzB0HiMBuaL1j/8ZLLTrnWKDOXAsOQ2f FHeu/5BMDMAQ0i19s6rm1/vYwanx3EnDZWjl9+rxsMMmHa9XgNYXVszxDBUQZ2BN13 aFtzNya2wKiOg== From: Masami Hiramatsu To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, Masami Hiramatsu , lkp@lists.01.org, lkp@intel.com, oliver.sang@intel.com Subject: [PATCH] bootconfig: Fix to check the xbc_node is used before free it Date: Mon, 13 Sep 2021 09:56:45 +0900 Message-Id: <163149460533.291098.7342418455457691240.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210912140820.GD25450@xsang-OptiPlex-9020> References: <20210912140820.GD25450@xsang-OptiPlex-9020> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix to check the xbc_node is used before calling memblock_free() because passing NULL to phys_addr() will cause a panic. This will happen if user doesn't pass any bootconfig to the kernel, because kernel will call xbc_destroy_all() after booting. Fixes: 40caa127f3c7 ("init: bootconfig: Remove all bootconfig data when the init memory is removed") Reported-by: kernel test robot Signed-off-by: Masami Hiramatsu --- lib/bootconfig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bootconfig.c b/lib/bootconfig.c index f8419cff1147..4f8849706ef6 100644 --- a/lib/bootconfig.c +++ b/lib/bootconfig.c @@ -792,7 +792,8 @@ void __init xbc_destroy_all(void) xbc_data = NULL; xbc_data_size = 0; xbc_node_num = 0; - memblock_free(__pa(xbc_nodes), sizeof(struct xbc_node) * XBC_NODE_MAX); + if (xbc_nodes) + memblock_free(__pa(xbc_nodes), sizeof(struct xbc_node) * XBC_NODE_MAX); xbc_nodes = NULL; brace_index = 0; }