[PATCH] device: add null check on `self->priv->modem' in clear_modem
Aleksander Morgado
aleksander at aleksander.es
Fri Mar 3 20:40:31 UTC 2017
On 03/03/17 20:26, Aleksander Morgado wrote:
> On Fri, Mar 3, 2017 at 7:29 PM, Ben Chan <benchan at chromium.org> wrote:
>> clear_modem() can be invoked from set_property() and dispose(), where
>> `self->priv->modem' may be NULL. This patch adds a null check on the
>> modem object to make sure we don't run g_object_run_dispose() on a null
>> modem object.
>> ---
>
> Yes, it may happen that clear_modem() is called as a result of the
> modem reporting "valid FALSE" when the primary port is lost; and then
> again when the MMDevice is disposed. This patch should fix that
> warning, LGTM.
>
And pushed to git master and also to the stable branches.
>
>> src/mm-device.c | 10 ++++++----
>> 1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/mm-device.c b/src/mm-device.c
>> index 803e64d3..6c856289 100644
>> --- a/src/mm-device.c
>> +++ b/src/mm-device.c
>> @@ -302,10 +302,12 @@ clear_modem (MMDevice *self)
>> self->priv->modem_valid_id = 0;
>> }
>>
>> - /* Run dispose before unref-ing, in order to cleanup the SIM object,
>> - * if any (which also holds a reference to the modem object) */
>> - g_object_run_dispose (G_OBJECT (self->priv->modem));
>> - g_clear_object (&(self->priv->modem));
>> + if (self->priv->modem) {
>> + /* Run dispose before unref-ing, in order to cleanup the SIM object,
>> + * if any (which also holds a reference to the modem object) */
>> + g_object_run_dispose (G_OBJECT (self->priv->modem));
>> + g_clear_object (&(self->priv->modem));
>> + }
>> }
>>
>> void
>> --
>> 2.12.0.rc1.440.g5b76565f74-goog
>>
>
>
>
--
Aleksander
https://aleksander.es
More information about the ModemManager-devel
mailing list