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