mirror-linux/kernel/power
Malaya Kumar Rout e25348c540 PM: EM: Fix memory leak in em_create_pd() error path
When ida_alloc() fails in em_create_pd(), the function returns without
freeing the previously allocated 'pd' structure, leading to a memory leak.
The 'pd' pointer is allocated either at line 436 (for CPU devices with
cpumask) or line 442 (for other devices) using kzalloc().

Additionally, the function incorrectly returns -ENOMEM when ida_alloc()
fails, ignoring the actual error code returned by ida_alloc(), which can
fail for reasons other than memory exhaustion.

Fix both issues by:
 1. Freeing the 'pd' structure with kfree() when ida_alloc() fails
 2. Returning the actual error code from ida_alloc() instead of -ENOMEM

This ensures proper cleanup on the error path and accurate error reporting.

Fixes: cbe5aeedec ("PM: EM: Assign a unique ID when creating a performance domain")
Signed-off-by: Malaya Kumar Rout <mrout@redhat.com>
Reviewed-by:  Changwoo Min <changwoo@igalia.com>
Link: https://patch.msgid.link/20260105103730.65626-1-mrout@redhat.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-01-08 16:55:21 +01:00
..
Kconfig PM: QoS: Introduce a CPU system wakeup QoS limit 2025-11-25 19:01:29 +01:00
Makefile PM: EM: Add a skeleton code for netlink notification 2025-10-22 21:44:37 +02:00
autosleep.c PM: sleep: autosleep: don't include 'pm_wakeup.h' directly 2024-12-05 12:14:26 +01:00
console.c PM: console: Fix memory allocation error handling in pm_vt_switch_required() 2025-10-18 14:38:23 +02:00
em_netlink.c PM: EM: Implement em_notify_pd_created/updated() 2025-10-22 21:44:38 +02:00
em_netlink.h PM: EM: Implement em_notify_pd_created/updated() 2025-10-22 21:44:38 +02:00
em_netlink_autogen.c ynl: add regen hint to new headers 2025-12-08 23:52:43 -08:00
em_netlink_autogen.h ynl: add regen hint to new headers 2025-12-08 23:52:43 -08:00
energy_model.c PM: EM: Fix memory leak in em_create_pd() error path 2026-01-08 16:55:21 +01:00
hibernate.c Merge branch 'pm-sleep' 2025-11-28 16:01:13 +01:00
main.c Merge branch 'pm-sleep' 2025-11-28 16:01:13 +01:00
power.h PM: sleep: Add support for wakeup during filesystem sync 2025-11-20 22:29:40 +01:00
poweroff.c tty: sysrq: switch sysrq handlers from int to u8 2023-07-25 19:21:03 +02:00
process.c Revert "PM: sleep: Make pm_wakeup_clear() call more clear" 2025-10-23 12:48:04 +02:00
qos.c PM: QoS: Introduce a CPU system wakeup QoS limit 2025-11-25 19:01:29 +01:00
snapshot.c PM: hibernate: Rework message printing in swsusp_save() 2025-10-20 20:43:09 +02:00
suspend.c PM: sleep: Fix suspend_test() at the TEST_CORE level 2025-12-28 13:01:39 +01:00
suspend_test.c rtc: class: make rtc_class constant 2024-03-08 12:05:10 +01:00
swap.c PM: hibernate: Extra cleanup of comments in swap handling code 2025-11-24 20:41:06 +01:00
user.c PM: sleep: Call pm_sleep_fs_sync() instead of ksys_sync_helper() 2025-11-20 22:29:40 +01:00
wakelock.c PM: wakeup: Delete space in the end of string shown by pm_show_wakelocks() 2025-05-09 15:48:39 +02:00