Patch "perf pmus: Fixes always false when compare duplicates aliases" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    perf pmus: Fixes always false when compare duplicates aliases

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     perf-pmus-fixes-always-false-when-compare-duplicates.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e3daa4e8acf6b2fc38db93b7b31280a2b50c72c1
Author: Junhao He <hejunhao3@xxxxxxxxxx>
Date:   Fri Jun 14 17:43:18 2024 +0800

    perf pmus: Fixes always false when compare duplicates aliases
    
    [ Upstream commit dd9a426eade634bf794c7e0f1b0c6659f556942f ]
    
    In the previous loop, all the members in the aliases[j-1] have been freed
    and set to NULL. But in this loop, the function pmu_alias_is_duplicate()
    compares the aliases[j] with the aliases[j-1] that has already been
    disposed, so the function will always return false and duplicate aliases
    will never be discarded.
    
    If we find duplicate aliases, it skips the zfree aliases[j], which is
    accompanied by a memory leak.
    
    We can use the next aliases[j+1] to theck for duplicate aliases to
    fixes the aliases NULL pointer dereference, then goto zfree code snippet
    to release it.
    
    After patch testing:
     $ perf list --unit=hisi_sicl,cpa pmu
    
     uncore cpa:
       cpa_p0_rd_dat_32b
            [Number of read ops transmitted by the P0 port which size is 32 bytes.
             Unit: hisi_sicl,cpa]
       cpa_p0_rd_dat_64b
            [Number of read ops transmitted by the P0 port which size is 64 bytes.
             Unit: hisi_sicl,cpa]
    
    Fixes: c3245d2093c1 ("perf pmu: Abstract alias/event struct")
    Signed-off-by: Junhao He <hejunhao3@xxxxxxxxxx>
    Cc: ravi.bangoria@xxxxxxx
    Cc: james.clark@xxxxxxx
    Cc: prime.zeng@xxxxxxxxxxxxx
    Cc: cuigaosheng1@xxxxxxxxxx
    Cc: jonathan.cameron@xxxxxxxxxx
    Cc: linuxarm@xxxxxxxxxx
    Cc: yangyicong@xxxxxxxxxx
    Cc: robh@xxxxxxxxxx
    Cc: renyu.zj@xxxxxxxxxxxxxxxxx
    Cc: kjain@xxxxxxxxxxxxx
    Cc: john.g.garry@xxxxxxxxxx
    Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
    Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240614094318.11607-1-hejunhao3@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c
index cec869cbe163a..54a237b2b8538 100644
--- a/tools/perf/util/pmus.c
+++ b/tools/perf/util/pmus.c
@@ -470,8 +470,8 @@ void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *p
 	qsort(aliases, len, sizeof(struct sevent), cmp_sevent);
 	for (int j = 0; j < len; j++) {
 		/* Skip duplicates */
-		if (j > 0 && pmu_alias_is_duplicate(&aliases[j], &aliases[j - 1]))
-			continue;
+		if (j < len - 1 && pmu_alias_is_duplicate(&aliases[j], &aliases[j + 1]))
+			goto free;
 
 		print_cb->print_event(print_state,
 				aliases[j].pmu_name,
@@ -484,6 +484,7 @@ void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *p
 				aliases[j].desc,
 				aliases[j].long_desc,
 				aliases[j].encoding_desc);
+free:
 		zfree(&aliases[j].name);
 		zfree(&aliases[j].alias);
 		zfree(&aliases[j].scale_unit);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux