Skip to content

main: Fix HoldProfile still happening when unauthorised

Bastien Nocera requested to merge wip/hadess/holdprofile-auth into main

The HoldProfile method was correctly throwing an error back to the caller but was still carrying on to hold a profile.

This could cause a double-free in the daemon, and unwanted profile changes for users.

** (power-profiles-daemon:55299): DEBUG: 10:48:10.411: (:1.0) requesting to hold profile 'performance', reason: ''
** (power-profiles-daemon:55299): DEBUG: 10:48:10.422: Setting active profile 'performance' for reason 'program-hold' (current: 'balanced')
==55299== Invalid read of size 8
==55299==    at 0x4AA40F9: g_type_check_instance_is_fundamentally_a (gtype.c:4088)
==55299==    by 0x4A8DA08: g_object_unref (gobject.c:3484)
==55299==    by 0x4B17702: UnknownInlinedFun (gmain.c:1666)
==55299==    by 0x4B17702: g_source_callback_unref (gmain.c:1659)
==55299==    by 0x4B1B8BB: g_source_destroy_internal (gmain.c:1331)
==55299==    by 0x4B1D47F: UnknownInlinedFun (gmain.c:3411)
==55299==    by 0x4B1D47F: g_main_context_dispatch (gmain.c:4099)
==55299==    by 0x4B72287: g_main_context_iterate.constprop.0 (gmain.c:4175)
==55299==    by 0x4B1C902: g_main_loop_run (gmain.c:4373)
==55299==    by 0x403C10: main (power-profiles-daemon.c:1006)
==55299==  Address 0x54edc60 is 0 bytes inside a block of size 104 free'd
==55299==    at 0x48430E4: free (vg_replace_malloc.c:872)
==55299==    by 0x4B220BC: g_free (gmem.c:199)
==55299==    by 0x4B3C6FF: g_slice_free1 (gslice.c:1183)
==55299==    by 0x4AA2EF4: g_type_free_instance (gtype.c:2008)
==55299==    by 0x49B4840: g_dbus_method_invocation_return_value_internal (gdbusmethodinvocation.c:528)
==55299==    by 0x4064F2: hold_profile (power-profiles-daemon.c:568)
==55299==    by 0x4064F2: handle_method_call (power-profiles-daemon.c:711)
==55299==    by 0x49A4451: call_in_idle_cb.lto_priv.0 (gdbusconnection.c:4916)
==55299==    by 0x4B1952A: g_idle_dispatch (gmain.c:5897)
==55299==    by 0x4B1D33E: UnknownInlinedFun (gmain.c:3381)
==55299==    by 0x4B1D33E: g_main_context_dispatch (gmain.c:4099)
==55299==    by 0x4B72287: g_main_context_iterate.constprop.0 (gmain.c:4175)
==55299==    by 0x4B1C902: g_main_loop_run (gmain.c:4373)
==55299==    by 0x403C10: main (power-profiles-daemon.c:1006)
==55299==  Block was alloc'd at
==55299==    at 0x484086F: malloc (vg_replace_malloc.c:381)
==55299==    by 0x4B257A8: g_malloc (gmem.c:106)
==55299==    by 0x4B3D1E4: g_slice_alloc (gslice.c:1072)
==55299==    by 0x4B3D84D: g_slice_alloc0 (gslice.c:1098)
==55299==    by 0x4AA81F4: g_type_create_instance (gtype.c:1911)
==55299==    by 0x4A8FCAC: g_object_new_internal (gobject.c:1945)
==55299==    by 0x4A90C7C: g_object_new_with_properties (gobject.c:2114)
==55299==    by 0x4A91780: g_object_new (gobject.c:1785)
==55299==    by 0x49D8033: UnknownInlinedFun (gdbusmethodinvocation.c:369)
==55299==    by 0x49D8033: schedule_method_call.constprop.0 (gdbusconnection.c:4946)
==55299==    by 0x49A45B9: validate_and_maybe_schedule_method_call.lto_priv.0 (gdbusconnection.c:5048)
==55299==    by 0x499C57A: UnknownInlinedFun (gdbusconnection.c:5091)
==55299==    by 0x499C57A: UnknownInlinedFun (gdbusconnection.c:7172)
==55299==    by 0x499C57A: UnknownInlinedFun (gdbusconnection.c:2344)
==55299==    by 0x499C57A: on_worker_message_received (gdbusconnection.c:2258)
==55299==    by 0x49B0082: UnknownInlinedFun (gdbusprivate.c:488)
==55299==    by 0x49B0082: UnknownInlinedFun (gdbusprivate.c:484)
==55299==    by 0x49B0082: UnknownInlinedFun (gdbusprivate.c:516)
==55299==    by 0x49B0082: _g_dbus_worker_do_read_cb (gdbusprivate.c:801)
==55299==

(power-profiles-daemon:55299): GLib-GObject-CRITICAL **: 10:48:10.427: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

Merge request reports