]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
perf dso: With ref count checking, avoid dso_data holding dso live
authorIan Rogers <irogers@google.com>
Tue, 24 Jun 2025 19:03:24 +0000 (12:03 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 3 Jul 2025 02:05:27 +0000 (19:05 -0700)
With the dso_data embedded in a dso there is a reference counted
pointer to the dso rather than using container_of with reference count
checking. This data can hold the dso live meaning that no dso__put
ever deletes it. Add a check for this case and close the dso_data when
it happens. There isn't an infinite loop as the dso_data clears the
file descriptor prior to putting on the dso.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250624190326.2038704-5-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/dso.c

index 057fcf4225ac7e0f1dcf44518295eb105dab0e9f..c6c1637e098c8e7d3e089d04cc8bfe5a313b9e58 100644 (file)
@@ -1612,6 +1612,10 @@ struct dso *dso__get(struct dso *dso)
 
 void dso__put(struct dso *dso)
 {
+#ifdef REFCNT_CHECKING
+       if (dso && dso__data(dso) && refcount_read(&RC_CHK_ACCESS(dso)->refcnt) == 2)
+               dso__data_close(dso);
+#endif
        if (dso && refcount_dec_and_test(&RC_CHK_ACCESS(dso)->refcnt))
                dso__delete(dso);
        else