Blame SOURCES/0028-DP-add-NULL-check-to-be_ptask_-enable-disable.patch

5fca41
From cb94d00f31d1d6b6fcaa69dbaa928031d2e7c092 Mon Sep 17 00:00:00 2001
5fca41
From: Sumit Bose <sbose@redhat.com>
5fca41
Date: Fri, 24 May 2019 09:18:25 +0200
5fca41
Subject: [PATCH 28/29] DP: add NULL check to be_ptask_{enable|disable}
5fca41
5fca41
Currently the files and the proxy provider do not provide a check online
5fca41
method (DPM_CHECK_ONLINE). The files provider because it can never go
5fca41
offline. The proxy provider because there is no generic way to check
5fca41
since the nature of the actual provider is unknown.
5fca41
5fca41
Since the method is missing check_if_online() jumps into the error
5fca41
handling block were we try to reset the offline state
5fca41
unconditionally. If there is no check_if_online_ptask, which never
5fca41
exists for the files provider and will not be available in the proxy
5fca41
provider as long as the backend is online, be_ptask_{enable|disable}
5fca41
will be called with a NULL pointer.
5fca41
5fca41
Related to https://pagure.io/SSSD/sssd/issue/4014
5fca41
5fca41
Reviewed-by: Tomas Halman <thalman@redhat.com>
5fca41
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
5fca41
(cherry picked from commit 2720d97ce2559a3a382caf8f669820f64d6097fe)
5fca41
---
5fca41
 src/providers/be_ptask.c | 29 +++++++++++++++++------------
5fca41
 1 file changed, 17 insertions(+), 12 deletions(-)
5fca41
5fca41
diff --git a/src/providers/be_ptask.c b/src/providers/be_ptask.c
5fca41
index dc3c57db5..c43351755 100644
5fca41
--- a/src/providers/be_ptask.c
5fca41
+++ b/src/providers/be_ptask.c
5fca41
@@ -352,26 +352,31 @@ done:
5fca41
 
5fca41
 void be_ptask_enable(struct be_ptask *task)
5fca41
 {
5fca41
-    if (task->enabled) {
5fca41
-        DEBUG(SSSDBG_MINOR_FAILURE, "Task [%s]: already enabled\n",
5fca41
-                                     task->name);
5fca41
-        return;
5fca41
-    }
5fca41
+    if (task != NULL) {
5fca41
+        if (task->enabled) {
5fca41
+            DEBUG(SSSDBG_MINOR_FAILURE, "Task [%s]: already enabled\n",
5fca41
+                                         task->name);
5fca41
+            return;
5fca41
+        }
5fca41
 
5fca41
-    DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: enabling task\n", task->name);
5fca41
+        DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: enabling task\n", task->name);
5fca41
 
5fca41
-    task->enabled = true;
5fca41
-    be_ptask_schedule(task, BE_PTASK_ENABLED_DELAY, BE_PTASK_SCHEDULE_FROM_NOW);
5fca41
+        task->enabled = true;
5fca41
+        be_ptask_schedule(task, BE_PTASK_ENABLED_DELAY,
5fca41
+                          BE_PTASK_SCHEDULE_FROM_NOW);
5fca41
+    }
5fca41
 }
5fca41
 
5fca41
 /* Disable the task, but if a request already in progress, let it finish. */
5fca41
 void be_ptask_disable(struct be_ptask *task)
5fca41
 {
5fca41
-    DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: disabling task\n", task->name);
5fca41
+    if (task != NULL) {
5fca41
+        DEBUG(SSSDBG_TRACE_FUNC, "Task [%s]: disabling task\n", task->name);
5fca41
 
5fca41
-    talloc_zfree(task->timer);
5fca41
-    task->enabled = false;
5fca41
-    task->period = task->orig_period;
5fca41
+        talloc_zfree(task->timer);
5fca41
+        task->enabled = false;
5fca41
+        task->period = task->orig_period;
5fca41
+    }
5fca41
 }
5fca41
 
5fca41
 void be_ptask_destroy(struct be_ptask **task)
5fca41
-- 
5fca41
2.20.1
5fca41