When the WARN_ON_ONCE(i >= tmigr_hierarchy_levels) assertion triggers, the function returns -EINVAL without freeing the 'stack' memory allocated via kzalloc_objs() at the beginning of the function. Add kfree(stack) before returning to prevent the memory leak.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -1847,8 +1847,10 @@ static int tmigr_setup_groups(struct tmigr_hierarchy *hier, unsigned int cpu, · 1846 unmodified lines | |||
| 1847 | } | 1847 | } |
| 1848 | 1848 | ||
| 1849 | /* Assert single root without parent */ | 1849 | /* Assert single root without parent */ |
| 1850 | if (WARN_ON_ONCE(i >= tmigr_hierarchy_levels)) | 1850 | if (WARN_ON_ONCE(i >= tmigr_hierarchy_levels)) { |
| 1851 | kfree(stack); | ||
| 1851 | return -EINVAL; | 1852 | return -EINVAL; |
| 1853 | } | ||
| 1852 | 1854 | ||
| 1853 | for (; i >= start_lvl; i--) { | 1855 | for (; i >= start_lvl; i--) { |
| 1854 | group = stack[i]; | 1856 | group = stack[i]; |