summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Diserholt <albert.diserholt@icomera.com>2014-10-10 14:19:03 +0200
committerAleksander Morgado <aleksander@aleksander.es>2014-10-10 14:27:10 +0200
commit95af3c04f757f1c498e3f944647ae890ce795223 (patch)
treeeb69a7c2de23a3deab563d14e675e8a20734b5da
parent164bcd3a5e20360a3b6ee9e8a43b31cdffe57d0d (diff)
libqmi-glib,proxy: fix segfault
This patch fixes a segfault caused by a race condition where an incoming request has just been accepted and allocated, but a device for it has yet to be opened, and an old request is closed. The checks prevent a strcmp against unexisting devices. https://bugs.freedesktop.org/show_bug.cgi?id=77335
-rw-r--r--src/libqmi-glib/qmi-proxy.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libqmi-glib/qmi-proxy.c b/src/libqmi-glib/qmi-proxy.c
index 16e003e..620234b 100644
--- a/src/libqmi-glib/qmi-proxy.c
+++ b/src/libqmi-glib/qmi-proxy.c
@@ -142,8 +142,8 @@ get_n_clients_with_device (QmiProxy *self,
for (l = self->priv->clients; l; l = g_list_next (l)) {
Client *client = l->data;
- if (device == client->device ||
- g_str_equal (qmi_device_get_path (device), qmi_device_get_path (client->device)))
+ if (client->device && (device == client->device ||
+ g_str_equal (qmi_device_get_path (device), qmi_device_get_path (client->device))))
n++;
}
@@ -171,8 +171,8 @@ connection_close (Client *client)
for (l = self->priv->devices; l; l = g_list_next (l)) {
QmiDevice *device_in_list = QMI_DEVICE (l->data);
- if (device == device_in_list ||
- g_str_equal (qmi_device_get_path (device), qmi_device_get_path (device_in_list))) {
+ if (device_in_list && (device == device_in_list ||
+ g_str_equal (qmi_device_get_path (device), qmi_device_get_path (device_in_list)))) {
g_debug ("closing device '%s': no longer used", qmi_device_get_path_display (device));
qmi_device_close (device_in_list, NULL);
g_object_unref (device_in_list);