Skip to content

Commit d4ba0b0

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Clean up error handling path of iio mapping
The error handling path of iio mapping looks fragile. We already fixed one issue caused by it, commit f797f05 ("perf/x86/intel/uncore: Fix for iio mapping on Skylake Server"). Clean up the error handling path and make the code robust. Reported-by: gushengxian <[email protected]> Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 87bf399 commit d4ba0b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/x86/events/intel/uncore_snbep.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,11 +3789,11 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type)
37893789
/* One more for NULL. */
37903790
attrs = kcalloc((uncore_max_dies() + 1), sizeof(*attrs), GFP_KERNEL);
37913791
if (!attrs)
3792-
goto err;
3792+
goto clear_topology;
37933793

37943794
eas = kcalloc(uncore_max_dies(), sizeof(*eas), GFP_KERNEL);
37953795
if (!eas)
3796-
goto err;
3796+
goto clear_attrs;
37973797

37983798
for (die = 0; die < uncore_max_dies(); die++) {
37993799
sprintf(buf, "die%ld", die);
@@ -3814,7 +3814,9 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type)
38143814
for (; die >= 0; die--)
38153815
kfree(eas[die].attr.attr.name);
38163816
kfree(eas);
3817+
clear_attrs:
38173818
kfree(attrs);
3819+
clear_topology:
38183820
kfree(type->topology);
38193821
clear_attr_update:
38203822
type->attr_update = NULL;

0 commit comments

Comments
 (0)