Corrected CAN queues locking for corner case - i.e. partially connected queue.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Sat, 1 Oct 2011 20:44:53 +0000 (22:44 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Sat, 1 Oct 2011 20:44:53 +0000 (22:44 +0200)
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
lincan/src/can_queue.c

index 6395207..a1aa1df 100644 (file)
@@ -586,8 +586,8 @@ int canqueue_disconnect_edge(struct canque_edge_t *qedge)
        } else {
                DEBUGQUE("canqueue_disconnect_edge called with not fully connected edge");
                if(inends) can_spin_lock_irqsave(&inends->ends_lock,flags);
-               if(outends) can_spin_lock(&outends->ends_lock);
-               flags=0;
+               else if(outends) can_spin_lock_irqsave(&outends->ends_lock,flags);
+               else flags=0;
        }
 
        can_spin_lock(&qedge->fifo.fifo_lock);
@@ -609,8 +609,8 @@ int canqueue_disconnect_edge(struct canque_edge_t *qedge)
        if(inends && outends) {
                canque_edge_unlock_both_ends(inends, outends, flags);
        } else {
-               if(outends) can_spin_unlock(&outends->ends_lock);
                if(inends) can_spin_unlock_irqrestore(&inends->ends_lock,flags);
+               else if(outends) can_spin_unlock_irqrestore(&outends->ends_lock,flags);
        }
 
        DEBUGQUE("canqueue_disconnect_edge %d returned %d\n",qedge->edge_num,ret);