telit: avoid leaking SIM object

We were getting the SIM object for all paths, but only using (and
disposing it) in the AFTER_POWER_UP_STEP_GET_SIM_IDENTIFIER step.

Update the logic to only retrieve, use and dispose the SIM object in
the step that is needed, and therefore avoid leaking it in the
remaining steps.
This commit is contained in:
Aleksander Morgado
2017-09-04 17:15:04 +02:00
parent 76916de313
commit be079381c0

View File

@@ -985,32 +985,36 @@ after_power_up_step (GTask *task)
{ {
AfterPowerUpContext *ctx; AfterPowerUpContext *ctx;
MMBroadbandModemTelit *self; MMBroadbandModemTelit *self;
MMBaseSim *sim = NULL;
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
self = g_task_get_source_object (task); self = g_task_get_source_object (task);
g_object_get (MM_BROADBAND_MODEM_TELIT (self),
MM_IFACE_MODEM_SIM, &sim,
NULL);
if (!sim) {
g_task_return_new_error (task,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"could not acquire sim object");
return;
}
switch (ctx->step) { switch (ctx->step) {
case AFTER_POWER_UP_STEP_FIRST: case AFTER_POWER_UP_STEP_FIRST:
/* Fall back on next step */ /* Fall back on next step */
ctx->step++; ctx->step++;
case AFTER_POWER_UP_STEP_GET_SIM_IDENTIFIER:
case AFTER_POWER_UP_STEP_GET_SIM_IDENTIFIER: {
MMBaseSim *sim = NULL;
g_object_get (MM_BROADBAND_MODEM_TELIT (self),
MM_IFACE_MODEM_SIM, &sim,
NULL);
if (!sim) {
g_task_return_new_error (task,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"could not acquire sim object");
return;
}
mm_base_sim_load_sim_identifier (sim, mm_base_sim_load_sim_identifier (sim,
(GAsyncReadyCallback)load_sim_identifier_ready, (GAsyncReadyCallback)load_sim_identifier_ready,
task); task);
g_object_unref (sim); g_object_unref (sim);
return; return;
}
case AFTER_POWER_UP_STEP_ENABLE_QSS_PARSING: case AFTER_POWER_UP_STEP_ENABLE_QSS_PARSING:
mm_dbg ("Stop ignoring #QSS"); mm_dbg ("Stop ignoring #QSS");
self->priv->parse_qss = TRUE; self->priv->parse_qss = TRUE;