Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2815624rwb; Mon, 15 Aug 2022 11:55:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR40XQSuEntfoZ+78bBI3NBLoD8goTDBr/gaIKisFYSAhyUB+gfQ52crbfU8ZJ+rYZ2pb5ka X-Received: by 2002:a17:907:1361:b0:730:e5c4:6eba with SMTP id yo1-20020a170907136100b00730e5c46ebamr11209155ejb.597.1660589732882; Mon, 15 Aug 2022 11:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589732; cv=none; d=google.com; s=arc-20160816; b=A7OxjMOFlLO9y+0TSj1k9lrQSGJBtzUBCDpkfXlwQA+H+NPFUKomoSkb/w3kjHwwaj aM1NxBFi9wJiNwW9nUy0dlADa6IVPPcxXsGzGaENHXMyvMc4c4DFwqwJmBVDEa2eoBK1 TBlUF/vOI8elArPNF1kQZjQAFcD70uRb2+Fyc0KsZVSxrq0ZDTWL5z9XwCssYitMHSOH dWHFHmxdOE1nkWd9Hzct9bthXhE43ztkAmI8XTS2vyXS/uxNZ3lVLsfA8lOglhmcf1Aw 51/UlMQdUAfB0ULVa69Z9H9voONhBYizRx98vdRgY1rNqnZGt9P1pT+Ah7NCFKgopnmR Dg7Q== 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=54onwgv6NfjgizC9ZpbG4XITMGaVCNaoi8blWvK1NWU=; b=MsmtzrF4268yAdYy8VHZ8GKAvM7bg6Q1YjqTD5viE9WZUl0u4y78oXQopWCzig5UEv v4UqNtop957QiojVD/unrwCsdGMBdYZ0JieFoE4ou7nhK++/83NhLBFI3kBihr8ZhuLe 9BqFqpaNhcWVuo9nxddL/dV/D+vm/nBTrtn5YoiLJl4gbwTcgibsdf9IwSmblxptm9fp Sul8sr3VUu1zuabUOumNBabTmNetkrK/Q0daYrAlqWgMCe2AkGY/swGlmi00WiKwPGcI CeQH1brjvY1s++G4YNX6xxpcUzMXA69UAF1WBQ2GY6V3xpJfjdNos+cO6BsYKezLIKmc CtGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="yBjuSUx/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a0564021e8d00b0043d85ca3c96si8589480edf.440.2022.08.15.11.55.04; Mon, 15 Aug 2022 11:55:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="yBjuSUx/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S241783AbiHOSma (ORCPT + 99 others); Mon, 15 Aug 2022 14:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240650AbiHOSjs (ORCPT ); Mon, 15 Aug 2022 14:39:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D26262E693; Mon, 15 Aug 2022 11:24:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0F0C960F23; Mon, 15 Aug 2022 18:24:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0540BC433C1; Mon, 15 Aug 2022 18:24:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587846; bh=fRAAddhRsAHDwptBTq1uHqpI89s3n65ppRpfsul8gAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yBjuSUx/c9QI5hhGh43fWq503vQ5wRh5PydkZp6+WTnfHFCt2HWVFvfzv0bOhYEWH 7Memzk8QwfwPBAAtDaeSWrfcEI24fCOxeXn/NDqeMAMKgETv0VsYW5jSIfw80P+rYw ETpek1tZIZAFL4ld8qjDziTj+dEn3MeJvRnb0Hz0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hsin-Yi Wang , AngeloGioacchino Del Regno , Ulf Hansson , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.15 213/779] PM: domains: Ensure genpd_debugfs_dir exists before remove Date: Mon, 15 Aug 2022 19:57:37 +0200 Message-Id: <20220815180346.383118585@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hsin-Yi Wang [ Upstream commit 37101d3c719386040ded735a5ec06974f1d94d1f ] Both genpd_debug_add() and genpd_debug_remove() may be called indirectly by other drivers while genpd_debugfs_dir is not yet set. For example, drivers can call pm_genpd_init() in probe or pm_genpd_init() in probe fail/cleanup path: pm_genpd_init() --> genpd_debug_add() pm_genpd_remove() --> genpd_remove() --> genpd_debug_remove() At this time, genpd_debug_init() may not yet be called. genpd_debug_add() checks that if genpd_debugfs_dir is NULL, it will return directly. Make sure this is also checked in pm_genpd_remove(), otherwise components under debugfs root which has the same name as other components under pm_genpd may be accidentally removed, since NULL represents debugfs root. Fixes: 718072ceb211 ("PM: domains: create debugfs nodes when adding power domains") Signed-off-by: Hsin-Yi Wang Reviewed-by: Greg Kroah-Hartman Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Ulf Hansson Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/base/power/domain.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 0f2e42f36851..7f3d21e6fdfb 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -219,6 +219,9 @@ static void genpd_debug_remove(struct generic_pm_domain *genpd) { struct dentry *d; + if (!genpd_debugfs_dir) + return; + d = debugfs_lookup(genpd->name, genpd_debugfs_dir); debugfs_remove(d); } -- 2.35.1