Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3026999rwb; Mon, 15 Aug 2022 16:25:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR5oYV45Qxpi46L+jeGbEZ8ly6D1kVPhs+cmkIziOkkSMujs9oMqdJFfPdJHWJOY3h4LPf0L X-Received: by 2002:a17:902:f0d4:b0:171:3c13:4bfd with SMTP id v20-20020a170902f0d400b001713c134bfdmr19001005pla.84.1660605914480; Mon, 15 Aug 2022 16:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605914; cv=none; d=google.com; s=arc-20160816; b=m3k9AfYXifK9RJcG1Elkd1iXLYmBH/luJ1qx4frnBq4LhE4nEyXygKd/gxbX15xDC1 zyPGER3hZRJr0aRLGotg/pvfXN3i0vFJjiQLmUmmRqZ/qt8RNYEdX+A01J4yP8QqC6Q5 v+7Hq9u5v3On84KSZLxaZklvpgaal9lobgde6IEtBwoqikG365WTLLnI8vJKlPSTbMei zQJtnPzUPs5BgrqhvejSqk4qC9IvO/r1G1JvbnRuJ0FcBqPOAQgeKimb/Hrwm2lQozzg S3PYZl5FbKwJC3QRj6WKXPhRbMeAkf9VSp3AeoxJYVifHNPXIEA1HgPkLM4TRphxMD5X 8R/w== 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=Jej4yFOSox0Re/IFcI/rfTqQoYXtPajVoHA3fk/nrwQ=; b=DBCe7zaHxHjd4kX9Qc1gIFYaxi0jAIS4mE7bkyLB7d2EcjwHxm3UzKH6lxCPeopSYl BdvzbuRWPvwRh0WIoOSEn0IpW5eHO6z8spKepm9XTGv4kERS1NlXfmxdBGnRjjM+I7r+ 2KqXEmhu2iLMFcff/Mn5cNy+X3BMB5PjROvlk6vt8/HZrZnS3G0hbIa2gaLZBtstm2iS K5KIRcC8HvizKbruGymzXHBG3ag5yeDmtFS1fGH66Vd3h/aunx448U1xBaTjuM43O0Ef vI2unSPRN3PGH4LvePfuvBvojmaLASMN0fMDJx2eGxcqwFkol/SKS23YO00FukfkK1QS zvXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="j/2xpWCI"; 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 e21-20020a170902ed9500b00172689f108csi5478295plj.146.2022.08.15.16.25.03; Mon, 15 Aug 2022 16:25:14 -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="j/2xpWCI"; 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 S244632AbiHOXD6 (ORCPT + 99 others); Mon, 15 Aug 2022 19:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233102AbiHOXCJ (ORCPT ); Mon, 15 Aug 2022 19:02:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F78913F235; Mon, 15 Aug 2022 12:58:11 -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 D046860FB5; Mon, 15 Aug 2022 19:58:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D07D6C433C1; Mon, 15 Aug 2022 19:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593490; bh=JakJzBZy+7VcDQGMFxM5A/u02FhPDwbKSsoPFj5Ofi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j/2xpWCIolgYp/OwuaTaJuS2mjd9G4pmqLhq9DEcFlSRvtr1+qtRhJlqXK691qEI8 yZok0ZVH3vfmisNsd7qikY05FzMGZ0VPK0+Oe9KGhbR6cIMymRA3UrMojVu+IQSEAc k4BWERc1LCpHHck1Lifebqw4j99CeX8gU8+Baq7o= 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.19 0275/1157] PM: domains: Ensure genpd_debugfs_dir exists before remove Date: Mon, 15 Aug 2022 19:53:51 +0200 Message-Id: <20220815180450.614437794@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 739e52cd4aba..55a10e6d4e2a 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -222,6 +222,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