Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3615505pxb; Mon, 24 Jan 2022 13:34:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxA0VlbY3vV8udMuvTfwgPVI4HWX+2I5pLiyDzmp6EbSEhQvsSV+3xxZm0DQ3Kp3S0nTWyN X-Received: by 2002:a17:90a:d913:: with SMTP id c19mr288413pjv.90.1643060084841; Mon, 24 Jan 2022 13:34:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060084; cv=none; d=google.com; s=arc-20160816; b=b88Y8REZlgEIGU1E18x61dvLUVkv9euM1xrAhTnLb8wMxUYmOhwiuO/rz2Z6blseR0 WfrzYPgFYlOf8CRHqTBqLW/z3N3bC3+fFQV1dr7Ot52uh/JvY8nuFsK4GLiYSxpuGWwV Yoq6gyDBBkwFoKOlfBn2PxnXcVdtj5N9cvhUwqRPTFQMXHfHQsq3FVmde33kM4WiYzjV sIg9sgbqs00iYMHFK4btaJtWkqz8yIiF6Opa95X6dpebRjqxRtWRH2OVh5IMlGWgrn2F wmsEiFEHEAHC67nKltb15v3gMOV70SezxD6GGTRr/mICXcgENzSSQRDBmD5rMYE1NAUD naUw== 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=Tf6OhrFNql7nMASee/Aw9YWowzPCgOsDKBYsNAZwjs4=; b=oI2/jwEWWYEcvEmfGSlCjY9X04SIZs07dYMZmoNeeMTcjPuiZTmgaEo46pebUihoq5 S6eydjzAHCyEARoTP7jcIoQvscXYT3QhBsQVsuGDkMeNUeXU1m40yl+8IDMhjx6+lRZI 1ee3yewy0KVALBRPEEXWIGdDWeIC6LLYF8h3ibJTISwwcJ1kbEUbPKDV+u3Rzn1IsI7W eLPtXlPLpXLal2Kz3FbMbMs8J1hhXOWpb4ef2vIKdUzOOHQlq06pBUvXZn9PfoPzGZD2 kp1pgAR32SkOj47Alv/AoLgolA/dUcY5mZJu8D4QMfbGCkVxEatqYYlMSI3/+6LvNi/m Mb4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CNI6UYPQ; 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 gf15si365714pjb.90.2022.01.24.13.34.32; Mon, 24 Jan 2022 13:34:44 -0800 (PST) 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=CNI6UYPQ; 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 S1448159AbiAXVMG (ORCPT + 99 others); Mon, 24 Jan 2022 16:12:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1389564AbiAXUmS (ORCPT ); Mon, 24 Jan 2022 15:42:18 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF66AC049646; Mon, 24 Jan 2022 11:52:26 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 8839EB81142; Mon, 24 Jan 2022 19:52:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9937BC340E7; Mon, 24 Jan 2022 19:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053945; bh=bRrlijC1F6GBDT2Rk+XS0Jz07Rmt6OW88U30+cWYSz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CNI6UYPQVKErXjOgJeMVanzoqel651bkT/6IxabeZKOhCCVzZyGrVlQNZXiPsszh2 PfZAoVH1FYQF+84+dJCU2iPr+pRBcbiDFReiSsdwoa5BUnJe4CvD1hzZdqCYkc+bRp tpLrbqRyLsQl0Wa+jFXTdw8JOtdwHf4gjo0pmF2A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown , Fabio Estevam , Sasha Levin Subject: [PATCH 5.10 229/563] regmap: Call regmap_debugfs_exit() prior to _init() Date: Mon, 24 Jan 2022 19:39:54 +0100 Message-Id: <20220124184032.369790263@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@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: Fabio Estevam [ Upstream commit 530792efa6cb86f5612ff093333fec735793b582 ] Since commit cffa4b2122f5 ("regmap: debugfs: Fix a memory leak when calling regmap_attach_dev"), the following debugfs error is seen on i.MX boards: debugfs: Directory 'dummy-iomuxc-gpr@20e0000' with parent 'regmap' already present! In the attempt to fix the memory leak, the above commit added a NULL check for map->debugfs_name. For the first debufs entry, map->debugfs_name is NULL and then the new name is allocated via kasprintf(). For the second debugfs entry, map->debugfs_name() is no longer NULL, so it will keep using the old entry name and the duplicate name error is seen. Quoting Mark Brown: "That means that if the device gets freed we'll end up with the old debugfs file hanging around pointing at nothing. ... To be more explicit this means we need a call to regmap_debugfs_exit() which will clean up all the existing debugfs stuff before we loose references to it." Call regmap_debugfs_exit() prior to regmap_debugfs_init() to fix the problem. Tested on i.MX6Q and i.MX6SX boards. Fixes: cffa4b2122f5 ("regmap: debugfs: Fix a memory leak when calling regmap_attach_dev") Suggested-by: Mark Brown Signed-off-by: Fabio Estevam Link: https://lore.kernel.org/r/20220107163307.335404-1-festevam@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/base/regmap/regmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 456a1787e18d0..55a30afc14a00 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -620,6 +620,7 @@ int regmap_attach_dev(struct device *dev, struct regmap *map, if (ret) return ret; + regmap_debugfs_exit(map); regmap_debugfs_init(map); /* Add a devres resource for dev_get_regmap() */ -- 2.34.1