[SSSD] [PATCH] DP: Remove processed callbacks

Jakub Hrozek jhrozek at redhat.com
Fri Dec 16 09:31:38 UTC 2011


I noticed that sss_dp_get_account_int_done() would free sdp_req but then
the callback destructor would dereference sdp_req as well. When the
destructor is called, sdp_req is already gone.

It looks that the callback is not needed after it has called the request
it links to so I think we can just free it and let the destructor
remove it from the list.
-------------- next part --------------
>From 9320a1b4c6cbf624fa7e5530d3c53d85adcb66a3 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Thu, 15 Dec 2011 14:40:01 +0100
Subject: [PATCH] DP: Remove processed callbacks

---
 src/responder/common/responder_dp.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/responder/common/responder_dp.c b/src/responder/common/responder_dp.c
index 93c7cae4dfa699265a3c77bd32ea755b49d45f75..f51e2496a165cc2b776af776f2e9d1ea75b8e62c 100644
--- a/src/responder/common/responder_dp.c
+++ b/src/responder/common/responder_dp.c
@@ -599,7 +599,7 @@ static void sss_dp_get_account_int_done(DBusPendingCall *pending, void *ptr)
     int ret;
     struct tevent_req *req;
     struct sss_dp_req *sdp_req;
-    struct sss_dp_callback *cb;
+    struct sss_dp_callback *cb, *prevcb = NULL;
     struct dp_get_account_int_state *state;
     struct dp_get_account_state *cb_state;
 
@@ -645,9 +645,11 @@ static void sss_dp_get_account_int_done(DBusPendingCall *pending, void *ptr)
             tevent_req_error(cb->req, ret);
         }
 
-        /* Remove each callback from the list as it's replied to */
-        DLIST_REMOVE(sdp_req->cb_list, cb);
+        /* Freeing the request removes it from the list */
+        if (prevcb) talloc_free(prevcb);
+        prevcb = cb;
     }
+    talloc_free(prevcb);
 
     /* We're done with this request. Free the sdp_req
      * This will clean up the hash table entry as well
-- 
1.7.7.4



More information about the sssd-devel mailing list