Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

isdn: pcbit: fix interruptible_sleep_on race

interruptible_sleep_on is racy and going away. In case of pcbit,
the driver would run into a timeout if the card is initialized
before we start waiting for it. This uses wait_event to fix the
race. In order to do this, the state machine handling for the
timeout case has to get trivially reorganized so we actually know
whether the timeout has occorred or not.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: netdev@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Arnd Bergmann and committed by
David S. Miller
e5b3fa15 c73b1f6a

+3 -3
+3 -3
drivers/isdn/pcbit/drv.c
··· 796 796 #endif 797 797 dev = (struct pcbit_dev *) ptr; 798 798 799 + dev->l2_state = L2_DOWN; 799 800 wake_up_interruptible(&dev->set_running_wq); 800 801 } 801 802 ··· 819 818 820 819 add_timer(&dev->set_running_timer); 821 820 822 - interruptible_sleep_on(&dev->set_running_wq); 821 + wait_event(dev->set_running_wq, dev->l2_state == L2_RUNNING || 822 + dev->l2_state == L2_DOWN); 823 823 824 824 del_timer(&dev->set_running_timer); 825 825 ··· 843 841 { 844 842 printk(KERN_DEBUG "pcbit: initialization failed\n"); 845 843 printk(KERN_DEBUG "pcbit: firmware not loaded\n"); 846 - 847 - dev->l2_state = L2_DOWN; 848 844 849 845 #ifdef DEBUG 850 846 printk(KERN_DEBUG "Bank3 = %02x\n",