Hi

I was just looking at source code file lib/ipmi_smi.c
I think this code seems to have a potential bugs.
But actually I haven't encountered a bug yet.

I try to make a patch.
It move a stop_timer handler before cleanup the pending_cmds.
And add a cmd_lock and cmd_handlers_lock.

Is my patch reasonable ?

Thanks in advance,
Naohiro Ooiwa.


Signed-off-by: Naohiro Ooiwa <[email protected]>
---
 ipmi_smi.c |   24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

--- lib/ipmi_smi.c.orig 2010-01-04 23:46:15.000000000 +0900
+++ lib/ipmi_smi.c      2011-01-31 11:20:21.000000000 +0900
@@ -188,8 +188,20 @@ smi_cleanup(ipmi_con_t *ipmi)
     if (smi->close_done)
        smi->close_done(ipmi, smi->close_cb_data);

+    if (smi->audit_info) {
+       rv = ipmi->os_hnd->stop_timer(ipmi->os_hnd, smi->audit_timer);
+       if (rv)
+           smi->audit_info->cancelled = 1;
+       else {
+           ipmi->os_hnd->free_timer(ipmi->os_hnd, smi->audit_timer);
+           ipmi_mem_free(smi->audit_info);
+       }
+    }
+
+    ipmi_lock(smi->cmd_lock);
     cmd = smi->pending_cmds;
     smi->pending_cmds = NULL;
+    ipmi_unlock(smi->cmd_lock);
     while (cmd) {
        ipmi_addr_t   *addr;
        unsigned int  addr_len;
@@ -216,24 +228,16 @@ smi_cleanup(ipmi_con_t *ipmi)
        cmd = next_cmd;
     }

+    ipmi_lock(smi->cmd_handlers_lock);
     hnd_to_free = smi->cmd_handlers;
     smi->cmd_handlers = NULL;
+    ipmi_unlock(smi->cmd_handlers_lock);
     while (hnd_to_free) {
        next_hnd = hnd_to_free->next;
        ipmi_mem_free(hnd_to_free);
        hnd_to_free = next_hnd;
     }

-    if (smi->audit_info) {
-       rv = ipmi->os_hnd->stop_timer(ipmi->os_hnd, smi->audit_timer);
-       if (rv)
-           smi->audit_info->cancelled = 1;
-       else {
-           ipmi->os_hnd->free_timer(ipmi->os_hnd, smi->audit_timer);
-           ipmi_mem_free(smi->audit_info);
-       }
-    }
-
     if (ipmi->oem_data_cleanup)
        ipmi->oem_data_cleanup(ipmi);
     ipmi_con_attr_cleanup(ipmi);

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Openipmi-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openipmi-developer

Reply via email to