Commit d4ba0b06 authored by Kan Liang's avatar Kan Liang Committed by Peter Zijlstra

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 f797f05d ("perf/x86/intel/uncore:
Fix for iio mapping on Skylake Server"). Clean up the error handling
path and make the code robust.
Reported-by: default avatargushengxian <gushengxian@yulong.com>
Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/40e66cf9-398b-20d7-ce4d-433be6e08921@linux.intel.com
parent 87bf399f
...@@ -3789,11 +3789,11 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type) ...@@ -3789,11 +3789,11 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type)
/* One more for NULL. */ /* One more for NULL. */
attrs = kcalloc((uncore_max_dies() + 1), sizeof(*attrs), GFP_KERNEL); attrs = kcalloc((uncore_max_dies() + 1), sizeof(*attrs), GFP_KERNEL);
if (!attrs) if (!attrs)
goto err; goto clear_topology;
eas = kcalloc(uncore_max_dies(), sizeof(*eas), GFP_KERNEL); eas = kcalloc(uncore_max_dies(), sizeof(*eas), GFP_KERNEL);
if (!eas) if (!eas)
goto err; goto clear_attrs;
for (die = 0; die < uncore_max_dies(); die++) { for (die = 0; die < uncore_max_dies(); die++) {
sprintf(buf, "die%ld", die); sprintf(buf, "die%ld", die);
...@@ -3814,7 +3814,9 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type) ...@@ -3814,7 +3814,9 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type)
for (; die >= 0; die--) for (; die >= 0; die--)
kfree(eas[die].attr.attr.name); kfree(eas[die].attr.attr.name);
kfree(eas); kfree(eas);
clear_attrs:
kfree(attrs); kfree(attrs);
clear_topology:
kfree(type->topology); kfree(type->topology);
clear_attr_update: clear_attr_update:
type->attr_update = NULL; type->attr_update = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment