From e437d201084bd946f5f98db37433098049433dd1 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 14 Oct 2015 12:12:39 +0200 Subject: [PATCH] device: Don't call fp_async_dev_close() with NULL device In some cases, the priv->dev is already freed and NULL, so ensure that we don't try to close NULL devices and crash. --- src/device.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/device.c b/src/device.c index 85d9353..df26f3a 100644 --- a/src/device.c +++ b/src/device.c @@ -556,9 +556,11 @@ _fprint_device_client_vanished (GDBusConnection *connection, done = FALSE; /* Close the claimed device as well */ - fp_async_dev_close (priv->dev, action_stop_cb, &done); - while (done == FALSE) - g_main_context_iteration (NULL, TRUE); + if (priv->dev) { + fp_async_dev_close (priv->dev, action_stop_cb, &done); + while (done == FALSE) + g_main_context_iteration (NULL, TRUE); + } g_free (priv->sender); priv->sender = NULL; @@ -728,7 +730,8 @@ static void fprint_device_release(FprintDevice *rdev, } session->context_release_device = context; - fp_async_dev_close(priv->dev, dev_close_cb, rdev); + if (priv->dev) + fp_async_dev_close(priv->dev, dev_close_cb, rdev); } static void verify_cb(struct fp_dev *dev, int r, struct fp_img *img,