LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] perf/core: Add missing device_remove_file() in pmu_dev_alloc()
@ 2021-08-09  3:49 Zhen Lei
  0 siblings, 0 replies; only message in thread
From: Zhen Lei @ 2021-08-09  3:49 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	linux-perf-users, linux-kernel
  Cc: Zhen Lei

The device attribute file 'nr_addr_filters' should be removed when
sysfs_update_groups() fails.

Fixes: f3a3a8257e5a ("perf/core: Add attr_groups_update into struct pmu")
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 kernel/events/core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 464917096e73..7d465584445b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10980,11 +10980,15 @@ static int pmu_dev_alloc(struct pmu *pmu)
 		ret = sysfs_update_groups(&pmu->dev->kobj, pmu->attr_update);
 
 	if (ret)
-		goto del_dev;
+		goto remove_file;
 
 out:
 	return ret;
 
+remove_file:
+	if (pmu->nr_addr_filters)
+		device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
+
 del_dev:
 	device_del(pmu->dev);
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-09  3:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09  3:49 [PATCH] perf/core: Add missing device_remove_file() in pmu_dev_alloc() Zhen Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).