All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 4/8] qmi: implement read_settings for automatic contexts
Date: Tue, 11 Apr 2017 12:02:28 -0500	[thread overview]
Message-ID: <f5e684d0-a177-30a8-cdfc-68af767e3c8b@gmail.com> (raw)
In-Reply-To: <20170411081818.19544-5-jonas@southpole.se>

[-- Attachment #1: Type: text/plain, Size: 2217 bytes --]

On 04/11/2017 03:18 AM, Jonas Bonn wrote:
> For LTE, a context is created automatically when the modem registers
> to the network.  The read_settings function is called for these
> automatic contexts to get their configuration.
> ---
>  drivers/qmimodem/gprs-context.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>

I went ahead and applied this patch, but see below:

> diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
> index 1ae2a5a..3841c7e 100644
> --- a/drivers/qmimodem/gprs-context.c
> +++ b/drivers/qmimodem/gprs-context.c
> @@ -153,6 +153,31 @@ done:
>  	g_free(cbd);
>  }
>
> +static void qmi_gprs_read_settings(struct ofono_gprs_context* gc,
> +					unsigned int cid,
> +					ofono_gprs_context_cb_t cb,
> +					void *user_data)
> +{
> +	struct cb_data *cbd = cb_data_new(cb, user_data);
> +	struct gprs_context_data *data = ofono_gprs_context_get_data(gc);
> +
> +	DBG("cid %u", cid);
> +
> +	data->active_context = cid;
> +
> +	cbd->user = gc;
> +
> +	if (qmi_service_send(data->wds, QMI_WDS_GET_SETTINGS, NULL,
> +					get_settings_cb, cbd, NULL) > 0)

You really should be setting the qmi_destroy_func_t for 
qmi_service_send.  This saves you a g_free call inside get_settings_cb, 
but more importantly it avoids a memory leak in case the 
qmi_service/qmi_device is destroyed before the callback has been called.

I went ahead and fixed this in the upstream code in commits:
f29a316c918bfd67072bdb4f46ca90a3b8954108
7a2e198fd7430c468f2a15ff82467c18c649ddf3

But there may be other instances of this bug lurking around.

> +		return;
> +
> +	data->active_context = 0;
> +
> +	CALLBACK_WITH_FAILURE(cb, cbd->data);
> +
> +	g_free(cbd);
> +}
> +
>  static void start_net_cb(struct qmi_result *result, void *user_data)
>  {
>  	struct cb_data *cbd = user_data;
> @@ -450,6 +475,7 @@ static struct ofono_gprs_context_driver driver = {
>  	.remove			= qmi_gprs_context_remove,
>  	.activate_primary	= qmi_activate_primary,
>  	.deactivate_primary	= qmi_deactivate_primary,
> +	.read_settings		= qmi_gprs_read_settings,
>  };
>
>  void qmi_gprs_context_init(void)
>

Regards,
-Denis

  reply	other threads:[~2017-04-11 17:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-11  8:18 [PATCH lte 0/8] QMI LTE series Jonas Bonn
2017-04-11  8:18 ` [PATCH 1/8] qmi: NAS definitions adjustment Jonas Bonn
2017-04-11 15:23   ` Denis Kenzior
2017-04-11  8:18 ` [PATCH 2/8] qmi: add WDS parameter definition Jonas Bonn
2017-04-11 16:23   ` Denis Kenzior
2017-04-11  8:18 ` [PATCH 3/8] qmi: retrieve GPRS context parameters Jonas Bonn
2017-04-11 16:44   ` Denis Kenzior
2017-04-11  8:18 ` [PATCH 4/8] qmi: implement read_settings for automatic contexts Jonas Bonn
2017-04-11 17:02   ` Denis Kenzior [this message]
2017-04-11  8:18 ` [PATCH 5/8] lte: activate default bearer on network registration Jonas Bonn
2017-04-11 17:07   ` Denis Kenzior
2017-04-11 20:48     ` Jonas Bonn
2017-04-11 21:21       ` Denis Kenzior
2017-04-12 14:28         ` Jonas Bonn
2017-04-12 21:10           ` Jonas Bonn
2017-04-13 15:14             ` Denis Kenzior
2017-04-14 21:53               ` Jonas Bonn
2017-04-14 23:18                 ` Denis Kenzior
2017-04-11  8:18 ` [PATCH 6/8] qmi: add LTE atom driver Jonas Bonn
2017-04-11 17:09   ` Denis Kenzior
2017-04-11  8:18 ` [PATCH 7/8] qmi: watch for automatic context activation Jonas Bonn
2017-04-11  8:18 ` [PATCH 8/8] gobi: add LTE atom Jonas Bonn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5e684d0-a177-30a8-cdfc-68af767e3c8b@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.