perf: qcom_l2_pmu: Make l2_cache_pmu_probe_cluster() more robust
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Thu, 18 May 2023 08:18:08 +0000 (10:18 +0200)
committerWill Deacon <will@kernel.org>
Mon, 5 Jun 2023 14:01:27 +0000 (15:01 +0100)
commit7bd42f122c7cf1e8101519dced3e07866b81e0d2
treeee7bbef002b3394a2e6331adac68e73244e7a138
parentf818947a06183dee7c2afc6648c75149586bf288
perf: qcom_l2_pmu: Make l2_cache_pmu_probe_cluster() more robust

If an error occurs after calling list_add(), the &l2cache_pmu->clusters
list will reference some memory that will be freed when the managed
resources will be released.

Move the list_add() at the end of the function when everything is in fine.

This is harmless because if l2_cache_pmu_probe_cluster() fails, then
l2_cache_pmu_probe() will fail as well and 'l2cache_pmu' will be released
as well.
But it looks cleaner and could silence static checker warning.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/6a0f5bdb6b7b2ed4ef194fc49693e902ad5b95ea.1684397879.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/qcom_l2_pmu.c