|
Tomas Bzatek |
dd2753 |
From cd458666a93fe9d07f3718e88f3169f01a11a63e Mon Sep 17 00:00:00 2001
|
|
Tomas Bzatek |
dd2753 |
From: Tomas Bzatek <tbzatek@redhat.com>
|
|
Tomas Bzatek |
dd2753 |
Date: Fri, 16 Apr 2021 18:36:16 +0200
|
|
Tomas Bzatek |
dd2753 |
Subject: [PATCH 7/8] udiskslinuxmdraidobject: Handle source attach failure
|
|
Tomas Bzatek |
dd2753 |
gracefully
|
|
Tomas Bzatek |
dd2753 |
|
|
Tomas Bzatek |
dd2753 |
Only negligible theoretical chance to hit this, reported by Coverity.
|
|
Tomas Bzatek |
dd2753 |
---
|
|
Tomas Bzatek |
dd2753 |
src/udiskslinuxmdraidobject.c | 10 ++++++++--
|
|
Tomas Bzatek |
dd2753 |
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
Tomas Bzatek |
dd2753 |
|
|
Tomas Bzatek |
dd2753 |
diff --git a/src/udiskslinuxmdraidobject.c b/src/udiskslinuxmdraidobject.c
|
|
Tomas Bzatek |
dd2753 |
index 20ca89c5..828c7058 100644
|
|
Tomas Bzatek |
dd2753 |
--- a/src/udiskslinuxmdraidobject.c
|
|
Tomas Bzatek |
dd2753 |
+++ b/src/udiskslinuxmdraidobject.c
|
|
Tomas Bzatek |
dd2753 |
@@ -468,7 +468,8 @@ watch_attr (UDisksLinuxDevice *device,
|
|
Tomas Bzatek |
dd2753 |
GError *error = NULL;
|
|
Tomas Bzatek |
dd2753 |
gchar *path = NULL;
|
|
Tomas Bzatek |
dd2753 |
GIOChannel *channel = NULL;
|
|
Tomas Bzatek |
dd2753 |
- GSource *ret = NULL;;
|
|
Tomas Bzatek |
dd2753 |
+ GSource *ret = NULL;
|
|
Tomas Bzatek |
dd2753 |
+ guint source_id;
|
|
Tomas Bzatek |
dd2753 |
|
|
Tomas Bzatek |
dd2753 |
g_return_val_if_fail (UDISKS_IS_LINUX_DEVICE (device), NULL);
|
|
Tomas Bzatek |
dd2753 |
|
|
Tomas Bzatek |
dd2753 |
@@ -478,9 +479,14 @@ watch_attr (UDisksLinuxDevice *device,
|
|
Tomas Bzatek |
dd2753 |
{
|
|
Tomas Bzatek |
dd2753 |
ret = g_io_create_watch (channel, G_IO_ERR);
|
|
Tomas Bzatek |
dd2753 |
g_source_set_callback (ret, callback, user_data, NULL);
|
|
Tomas Bzatek |
dd2753 |
- g_source_attach (ret, g_main_context_get_thread_default ());
|
|
Tomas Bzatek |
dd2753 |
+ source_id = g_source_attach (ret, g_main_context_get_thread_default ());
|
|
Tomas Bzatek |
dd2753 |
g_source_unref (ret);
|
|
Tomas Bzatek |
dd2753 |
g_io_channel_unref (channel); /* the keeps a reference to this object */
|
|
Tomas Bzatek |
dd2753 |
+ if (source_id == 0)
|
|
Tomas Bzatek |
dd2753 |
+ {
|
|
Tomas Bzatek |
dd2753 |
+ /* something bad happened while attaching the source */
|
|
Tomas Bzatek |
dd2753 |
+ ret = NULL;
|
|
Tomas Bzatek |
dd2753 |
+ }
|
|
Tomas Bzatek |
dd2753 |
}
|
|
Tomas Bzatek |
dd2753 |
else
|
|
Tomas Bzatek |
dd2753 |
{
|
|
Tomas Bzatek |
dd2753 |
--
|
|
Tomas Bzatek |
dd2753 |
2.30.2
|
|
Tomas Bzatek |
dd2753 |
|