Received: by 10.223.185.116 with SMTP id b49csp3671977wrg; Tue, 6 Mar 2018 03:05:39 -0800 (PST) X-Google-Smtp-Source: AG47ELvOjj7MzxgeMzy/9bvxU4DT1svAvJtjSJlEuWPeW01pjdLyyqYwKVGO6A46aCTOjrPu4Yiz X-Received: by 2002:a17:902:ad0b:: with SMTP id i11-v6mr8102403plr.10.1520334339327; Tue, 06 Mar 2018 03:05:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520334339; cv=none; d=google.com; s=arc-20160816; b=nQU2slctJGlXBYnHEyKihj79u6YbiRYK/dChutyqjOh2gJAv6ANysNcA1LzK6Fv+ht SIS+8rPC9g7ajXTh8cN7552+96AwuZLpYoATW9S+vaCMsM6jg8gPtTIzGXx2flOxZ8cu u2r44c1qYeTDl6rtvyLzqbk6x7O8IMiwCFY2E+PbNnSSVafF/3szuTNYxoInPV5Vqibi t+s3P3C/qK7bETQBjfaKek9yvxUYxrZREe4N5IpObMgNidPRUgbZjlErJ5/4cY1zyfRg t+5IFfobU2eAW+vjklS+a1WKIl8Gs1JF1ggfmA6yjKmSxRrj9bAQvU861fr9yQVRSeIS +xGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=FiG31vPoBhZiBscQ2hVnbZaVI0UMwPNVG8Zq3+3w5mU=; b=MuDVYNzogJQxRgFmQ1lcfVqaMvEk84rkGr6JYhzjddjVO50sdC6jIsxFo0CXN7Ag1U hnQSVlu6zwB+6mRpXhFHkDTdYn/oOVfjw8YJTriCU78XjAvT+78tgODheAk6I6wa3938 VR53LafzbqtpecUbesSw+j/pyWfyYtXr88kmyRiCMy8v1UEHJV9alG5fHiqZ4cSFVquf iDeI/eRz5LktQdIxKtLa93hROLzLH66u2WdvCdEWr9bjYkqpymUpgrD0yh9wiMBfWNFJ D8Jd3JfuoCIuWY5VqBH/hUKmVFXbPLsnbzVKeo34U5AALej7TP+nleYNxFxzGdooh80h aHZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j191si9661605pge.369.2018.03.06.03.05.24; Tue, 06 Mar 2018 03:05:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753024AbeCFLEW (ORCPT + 99 others); Tue, 6 Mar 2018 06:04:22 -0500 Received: from regular1.263xmail.com ([211.150.99.130]:47397 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750817AbeCFLEU (ORCPT ); Tue, 6 Mar 2018 06:04:20 -0500 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.227]) by regular1.263xmail.com (Postfix) with ESMTP id 1A396B196; Tue, 6 Mar 2018 19:04:16 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id D54A3375; Tue, 6 Mar 2018 19:04:12 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <4f232d89f9933886e547d38f35e06fb9> X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 7827FGEVYS; Tue, 06 Mar 2018 19:04:16 +0800 (CST) From: Jeffy Chen To: linux-kernel@vger.kernel.org Cc: Jeffy Chen , Greg Kroah-Hartman , Mark Brown Subject: [PATCH v2 2/3] regmap: debugfs: Fix kmemleak in regmap_debugfs_init Date: Tue, 6 Mar 2018 19:04:02 +0800 Message-Id: <20180306110403.14438-2-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180306110403.14438-1-jeffy.chen@rock-chips.com> References: <20180306110403.14438-1-jeffy.chen@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use map->debugfs_name to store allocated debugfs name, so it would be freed in regmap_debugfs_exit(). Kmemleak reported: unreferenced object 0xffffffc0cf78cf00 (size 128): comm "swapper/0", pid 1, jiffies 4294669168 (age 89.152s) hex dump (first 32 bytes): 64 75 6d 6d 79 32 33 00 00 00 00 00 00 00 00 00 dummy23......... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<0000000027429160>] kmemleak_alloc+0x58/0x8c [<0000000081861ddf>] __kmalloc_track_caller+0x1dc/0x2bc [<00000000258a341f>] kvasprintf+0xd0/0x168 [<00000000f3243f27>] kasprintf+0xac/0xd8 [<000000005f585642>] regmap_debugfs_init+0x1a0/0x3b0 [<000000002c08b110>] __regmap_init+0x12b8/0x135c [<00000000f64bcddb>] __regmap_init_mmio_clk+0x70/0x84 [<000000009c8f06b5>] of_syscon_register+0x278/0x378 [<0000000087e6c121>] syscon_node_to_regmap+0x80/0xb0 Fixes: a430ab205d29 ("regmap: debugfs: Disambiguate dummy debugfs file name") Signed-off-by: Jeffy Chen --- drivers/base/regmap/regmap-debugfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index e3e7b91cc421..5479a183248f 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c @@ -570,15 +570,15 @@ void regmap_debugfs_init(struct regmap *map, const char *name) map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s", devname, name); name = map->debugfs_name; + } else if (!map->dev) { + map->debugfs_name = kasprintf(GFP_KERNEL, "%s%d", + devname, dummy_index); + name = map->debugfs_name; + dummy_index++; } else { name = devname; } - if (!strcmp(name, "dummy")) { - name = kasprintf(GFP_KERNEL, "dummy%d", dummy_index); - dummy_index++; - } - map->debugfs = debugfs_create_dir(name, regmap_debugfs_root); if (!map->debugfs) { dev_warn(map->dev, "Failed to create debugfs directory\n"); -- 2.11.0