Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1540025pxb; Thu, 16 Sep 2021 09:31:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/+Sc1yF6wX0pxfDa/992oYyTkb05W4MyMCW3/+WlpLs5x9Wn4HJcqdaSHCJp+YjyijPNM X-Received: by 2002:a05:6638:372a:: with SMTP id k42mr5089886jav.71.1631809881483; Thu, 16 Sep 2021 09:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631809881; cv=none; d=google.com; s=arc-20160816; b=KEoQqQykYvXHY6C1OFahhHjUaWggYBjWoTFXVWETjjtH1YDb8Yqz2KkiqicuaHh7+P CasPHqlQPVW6j2mgptVElBe/iNkcQCvWFZ/l3wpbzHK5U/aZ6Lfmh6DJALWNRPNunI7T Xqwwz3wwmsGOg4HjAQBFpWCyfhlTUpXbQ5aun46dGum04dF26KcaZ4/bm8JSadlxw8x7 1fvH9O1OTlSm1VQf53yErRoaDaJeumsGsa8ngBrvfrzb0N/HWgAcBKZLxB0KmiWQY3UE g2pQuuvLlw3ukYcapq+WBghTJsosfo5G+R/P3qNH5LnADZKUiJeALNbFkGcUZiIK9QrN jsBw== 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=nmbQ5fW07I2JuJKIDYzD7SdtFtLwB+J4R3yeG17ZvZM=; b=qu7/H6ETjXlPbpJxgYmDBuGW1I72gBFjmyOTWzOmva8qglK5JIgOPwCOM2PYa6dXdL miP3JTnr3MxoFDGtkZpOH7vXbzvUnz5P+VOfJj3CG3Bf5PHalkVl2AB6t4SxRGwh5Qc6 i9Jh7CnmTibtDAODpGVZPSNy1BsFHBQNLp6sd6NN3/rj6+3ayGEchUHa4Y/AfaNP65VX f05uPi3ROBBxo0hDGA0+MO/Lcgb5NcnUPz4ehnyPhpeT/RvSrcNVeMyUu2YPgN3fOyZm bQAonTqcXAyachM8z3dDQty7vqU9G7bbHNgMYz+gnsLeByr2Jl3hqBOLYPRkRtyLd19Q 22zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0tbEEdDo; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n16si3925770jan.32.2021.09.16.09.31.06; Thu, 16 Sep 2021 09:31:21 -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=@linuxfoundation.org header.s=korg header.b=0tbEEdDo; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243216AbhIPQaL (ORCPT + 99 others); Thu, 16 Sep 2021 12:30:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:59282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241458AbhIPQVg (ORCPT ); Thu, 16 Sep 2021 12:21:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C1DAA613A7; Thu, 16 Sep 2021 16:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808899; bh=C56UGu/jYrwM6Jfi/51pH9IQNP0Jn9eLUHEN3yNrW1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0tbEEdDovYUox7gH1wErXY3em/dCo4dNxSXKhVbyh7ffZyeN9/2yL434pxXq0YfRC 3reMjStySNdG+oq2tXhub3umLMMWY2UOs0BVgYTymlRBWRmUE0T8fV+L0R3zJsUd0W oJmgHKNt1s5vmxKKQGD00jrfcT/WyR6WwCGhJU2g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Rob Herring , Sasha Levin Subject: [PATCH 5.10 246/306] of: Dont allow __of_attached_node_sysfs() without CONFIG_SYSFS Date: Thu, 16 Sep 2021 17:59:51 +0200 Message-Id: <20210916155802.446364467@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Marc Zyngier [ Upstream commit 6211e9cb2f8faf7faae0b6caf844bfe9527cc607 ] Trying to boot without SYSFS, but with OF_DYNAMIC quickly results in a crash: [ 0.088460] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000070 [...] [ 0.103927] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.14.0-rc3 #4179 [ 0.105810] Hardware name: linux,dummy-virt (DT) [ 0.107147] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--) [ 0.108876] pc : kernfs_find_and_get_ns+0x3c/0x7c [ 0.110244] lr : kernfs_find_and_get_ns+0x3c/0x7c [...] [ 0.134087] Call trace: [ 0.134800] kernfs_find_and_get_ns+0x3c/0x7c [ 0.136054] safe_name+0x4c/0xd0 [ 0.136994] __of_attach_node_sysfs+0xf8/0x124 [ 0.138287] of_core_init+0x90/0xfc [ 0.139296] driver_init+0x30/0x4c [ 0.140283] kernel_init_freeable+0x160/0x1b8 [ 0.141543] kernel_init+0x30/0x140 [ 0.142561] ret_from_fork+0x10/0x18 While not having sysfs isn't a very common option these days, it is still expected that such configuration would work. Paper over it by bailing out from __of_attach_node_sysfs() if CONFIG_SYSFS isn't enabled. Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20210820144722.169226-1-maz@kernel.org Signed-off-by: Rob Herring Signed-off-by: Sasha Levin --- drivers/of/kobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index a32e60b024b8..6675b5e56960 100644 --- a/drivers/of/kobj.c +++ b/drivers/of/kobj.c @@ -119,7 +119,7 @@ int __of_attach_node_sysfs(struct device_node *np) struct property *pp; int rc; - if (!of_kset) + if (!IS_ENABLED(CONFIG_SYSFS) || !of_kset) return 0; np->kobj.kset = of_kset; -- 2.30.2