[DRBD-cvs] drbd by lars; avoid NULL dereference in 2.4 backport o...
drbd-user@lists.linbit.com
drbd-user@lists.linbit.com
Sat, 5 Jun 2004 10:11:42 +0200 (CEST)
DRBD CVS committal
Author : lars
Module : drbd
Dir : drbd/drbd
Modified Files:
Tag: rel-0_7-branch
drbd_receiver.c
Log Message:
avoid NULL dereference in 2.4 backport of finish_wait
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/drbd_receiver.c,v
retrieving revision 1.97.2.165
retrieving revision 1.97.2.166
diff -u -3 -r1.97.2.165 -r1.97.2.166
--- drbd_receiver.c 1 Jun 2004 14:29:07 -0000 1.97.2.165
+++ drbd_receiver.c 5 Jun 2004 08:11:37 -0000 1.97.2.166
@@ -248,11 +248,11 @@
{
unsigned long flags;
+ __set_current_state(state);
wait->flags &= ~WQ_FLAG_EXCLUSIVE;
spin_lock_irqsave(&q->lock, flags);
if (list_empty(&wait->task_list))
__add_wait_queue(q, wait);
- set_current_state(state);
spin_unlock_irqrestore(&q->lock, flags);
}
@@ -261,10 +261,11 @@
unsigned long flags;
__set_current_state(TASK_RUNNING);
-
- spin_lock_irqsave(&q->lock, flags);
- list_del_init(&wait->task_list);
- spin_unlock_irqrestore(&q->lock, flags);
+ if (!list_empty(&wait->task_list)) {
+ spin_lock_irqsave(&q->lock, flags);
+ list_del_init(&wait->task_list);
+ spin_unlock_irqrestore(&q->lock, flags);
+ }
}
#define DEFINE_WAIT(name) DECLARE_WAITQUEUE(name,current)