Hi Lukasz,
On 03/27/2017 03:56 AM, Lukasz Nowak wrote:
From: Lukasz Nowak <[email protected]>
The qmimodem driver sets up numerous timeouts, passing internal
data structures to them as user_data. If a physical modem device
is removed, udev will call modem_unregister, which in turn will
call gobi_remove(). That function calls qmi_device_unref() which
frees all internal data structure memory inside qmidriver.
If a timeout is in progress while the usb device is removed,
the callback function will operate on already freed memory,
causing unpredicatble results. In some cases nothing bad will
happen, in others - segfault.
In order to solve this problem, add calls to qmi_device_ref
before setting up each timeout. Then inside callbacks, check
if this is the last reference (i.e. gobi_remove() has been called).
If that happens, do not operate on memory, just clean-up and exit.
No, this is not the right way of doing this. The proper way to do this
is to store the glib gsource identifier for every timeout and remove
that timeout in the appropriate place / time.
I only see about 5 g_timeout_add calls inside qmi.c where the return
value isn't saved off. So you probably need to go through these and
save the gsource id in the appropriate data structure.
Regards,
-Denis
_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono