broadband-modem-mbim: SIM slots ptr array should have GDestroyNotify

The SIM slots ptr array should have a proper GDestroyNotify, so that
whenever the array is unref-ed as part of the modem disposal logic,
the SIM objects (and the modem object references they keep) are also
unref-ed.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/571
This commit is contained in:
Aleksander Morgado
2022-08-04 17:51:34 +02:00
parent a783d9f68a
commit 4a62ea3e84

View File

@@ -8405,6 +8405,13 @@ load_sim_slots_context_free (LoadSimSlotsContext *ctx)
g_slice_free (LoadSimSlotsContext, ctx); g_slice_free (LoadSimSlotsContext, ctx);
} }
static void
sim_slot_free (MMBaseSim *sim)
{
if (sim)
g_object_unref (sim);
}
static gboolean static gboolean
load_sim_slots_finish (MMIfaceModem *self, load_sim_slots_finish (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
@@ -8632,7 +8639,7 @@ query_sys_caps_ready (MbimDevice *device,
return; return;
} }
ctx->number_slots = number_slots; ctx->number_slots = number_slots;
ctx->sim_slots = g_ptr_array_new_full (number_slots, NULL); ctx->sim_slots = g_ptr_array_new_full (number_slots, (GDestroyNotify) sim_slot_free);
if (number_executors == 0) { if (number_executors == 0) {
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND, g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND,