diff options
author | Denis Kenzior <denkenz@gmail.com> | 2024-04-15 10:03:20 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2024-04-16 15:33:24 -0500 |
commit | 844b488b2919d5af4bf9d8c8278344ab354abeb7 (patch) | |
tree | dfb550124510c66a7de60988e9f7b44eb0cc97b5 | |
parent | 417517a5849ec3076eed1c6b68f70eadd8d1a2f4 (diff) | |
download | ofono-844b488b2919d5af4bf9d8c8278344ab354abeb7.tar.gz |
qmi: gprs-context: Do not free/alloc unnecessarily
In start_net_cb, a new cb_data object is allocated which contains the
exact same information as the cb_data object being passed in as
userdata. Use cb_data_ref/unref instead.
While here, also fix an erroneous invocation of CALLBACK_WITH_SUCCESS if
the GET_CURRENT_SETTINGS request was not queued successfully. An error
should be generated instead.
-rw-r--r-- | drivers/qmimodem/gprs-context.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index cbe338619..1d7449e68 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -166,17 +166,12 @@ static void start_net_cb(struct qmi_result *result, void *user_data) data->pkt_handle = handle; - /* Duplicate cbd, the old one will be freed when this method returns */ - cbd = cb_data_new(cb, cbd->data); - cbd->user = gc; if (qmi_service_send(data->wds, QMI_WDS_GET_CURRENT_SETTINGS, NULL, - get_settings_cb, cbd, l_free) > 0) + get_settings_cb, cbd, cb_data_unref) > 0) { + cb_data_ref(cbd); return; - - CALLBACK_WITH_SUCCESS(cb, cbd->data); - - return; + } error: data->active_context = 0; @@ -205,7 +200,7 @@ static void qmi_gprs_read_settings(struct ofono_gprs_context* gc, cbd->user = gc; if (qmi_service_send(data->wds, QMI_WDS_START_NETWORK, NULL, - start_net_cb, cbd, l_free) > 0) + start_net_cb, cbd, cb_data_unref) > 0) return; data->active_context = 0; @@ -277,7 +272,7 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc, strlen(ctx->password), ctx->password); if (qmi_service_send(data->wds, QMI_WDS_START_NETWORK, param, - start_net_cb, cbd, l_free) > 0) + start_net_cb, cbd, cb_data_unref) > 0) return; qmi_param_free(param); |