Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4184666pxk; Tue, 8 Sep 2020 12:55:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGwAFOZN9clR29JNL0o8X/13za6xOOhIAZHDIUsiZ3ZZkHCSHHWzqJsOEFn6piKon09lnL X-Received: by 2002:aa7:d458:: with SMTP id q24mr703212edr.23.1599594926376; Tue, 08 Sep 2020 12:55:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599594926; cv=none; d=google.com; s=arc-20160816; b=kg+H3kiAtx9dPCGFrrNxQZGx/CuVH42Rv9iJJbkkEmiNv+rn3eNrfflQDTRlDFfVJ5 Cr5CCYy/3UwTD7eZNsGFEhHRJpiKqZ7GQq2nqg13VWyJBoZJk7+SG/D5d1rpOKzDVFBI YK/lVGUkWwlHlExeeztLRD0wavWfVLCFDCr8okabAdxq+GkrS1byUHNcQbFF9l2uYR9g 45+txleRmjMJAb6VtsZh+rs7kA5QHAtDBpHtvYkOAdJagAwez2Qk/LCho6pdetpnE4l3 ITrVzbR+IHowoJRSkI9PZny6+qSKI/mtjCFRO7358wa7udRjPDtPxXZ8uvA/pEXEqzV0 NMNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=He8NBx+FDWz3/bMowlIoIDe2LTAB1FkE8m09ErHjUUk=; b=nUhTnq4AcLz8qSbLk+D6K9o+nvxIvKXHYOaZRJh61VDTK3yQoku9nVsyuY4NPuKwep Ryc7JdedBrfgyrRz0UbAZiBavVZmcHReGTon86d4dLBjXJGR4P5Fj7OA3Gmh/cxUbFP+ YS9HYGqN72lsNXUHIpCcRvlwn3Azx0lZBOcbCVnkIcQgK0J4JN4LLWrZEoGR0cUu4iAo 8di4WKbI1+RBGIXeA4s7+zYG2krJ+nEaO9AKaM0JwbVlTR0wtdJHVPDU0t2O/36nW8Bg d8hMzuAOYFLB9C/V0essGDNMU+F4r6urRuFG2G+JHMAdY0YPPMdNSYoE5ydSrzDOVpni ziXw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si24189ejq.317.2020.09.08.12.55.03; Tue, 08 Sep 2020 12:55:26 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731237AbgIHTy0 (ORCPT + 99 others); Tue, 8 Sep 2020 15:54:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730631AbgIHPhg (ORCPT ); Tue, 8 Sep 2020 11:37:36 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CB59C0619C6 for ; Tue, 8 Sep 2020 08:29:12 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id B60AA28CBC9 From: Dafna Hirschfeld To: linux-kernel@vger.kernel.org, rafael@kernel.org, gregkh@linuxfoundation.org, broonie@kernel.org Cc: enric.balletbo@collabora.com, kernel@collabora.com, dafna3@gmail.com, Dafna Hirschfeld Subject: [PATCH] regmap: debugfs: potentially duplicate the name string of the config Date: Tue, 8 Sep 2020 17:28:59 +0200 Message-Id: <20200908152859.26279-1-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In function regmap_debugfs_init the name of the regmap_config is assigned in a node of regmap_debugfs_early_list to be used later after regmap is initialized. It is unknown how and when the name is allocated and freed. Therefore the name should be copied to the node using 'kstrdup_const'. This fixes an error "debugfs: Directory 'dummy-' with parent 'regmap' already present!" where the name was freed in function of_syscon_register before it was accessed. Fixes: a52eaeb1898bc (regmap: debugfs: Fix a boot time crash with early regmap init) Signed-off-by: Dafna Hirschfeld --- drivers/base/regmap/regmap-debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index f58baff2be0a..0845c4a2e33e 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c @@ -569,7 +569,7 @@ void regmap_debugfs_init(struct regmap *map, const char *name) if (!node) return; node->map = map; - node->name = name; + node->name = kstrdup_const(name, GFP_KERNEL); mutex_lock(®map_debugfs_early_lock); list_add(&node->link, ®map_debugfs_early_list); mutex_unlock(®map_debugfs_early_lock); @@ -664,6 +664,7 @@ void regmap_debugfs_exit(struct regmap *map) link) { if (node->map == map) { list_del(&node->link); + kfree_const(node->name); kfree(node); } } @@ -681,6 +682,7 @@ void regmap_debugfs_initcall(void) list_for_each_entry_safe(node, tmp, ®map_debugfs_early_list, link) { regmap_debugfs_init(node->map, node->name); list_del(&node->link); + kfree_const(node->name); kfree(node); } mutex_unlock(®map_debugfs_early_lock); -- 2.17.1