Skip to content

Commit 7bd42f1

Browse files
tititiou36willdeacon
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/6a0f5bdb6b7b2ed4ef194fc49693e902ad5b95ea.1684397879.git.christophe.jaillet@wanadoo.fr Signed-off-by: Will Deacon <[email protected]>
1 parent f818947 commit 7bd42f1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/perf/qcom_l2_pmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,6 @@ static int l2_cache_pmu_probe_cluster(struct device *dev, void *data)
857857
return -ENOMEM;
858858

859859
INIT_LIST_HEAD(&cluster->next);
860-
list_add(&cluster->next, &l2cache_pmu->clusters);
861860
cluster->cluster_id = fw_cluster_id;
862861

863862
irq = platform_get_irq(sdev, 0);
@@ -883,6 +882,7 @@ static int l2_cache_pmu_probe_cluster(struct device *dev, void *data)
883882

884883
spin_lock_init(&cluster->pmu_lock);
885884

885+
list_add(&cluster->next, &l2cache_pmu->clusters);
886886
l2cache_pmu->num_pmus++;
887887

888888
return 0;

0 commit comments

Comments
 (0)