Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752349AbaABMMj (ORCPT ); Thu, 2 Jan 2014 07:12:39 -0500 Received: from moutng.kundenserver.de ([212.227.126.186]:54324 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811AbaABMIc (ORCPT ); Thu, 2 Jan 2014 07:08:32 -0500 From: Arnd Bergmann To: linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Karsten Keil , netdev@vger.kernel.org Subject: [PATCH, RFC 21/30] isdn: divert, hysdn: fix interruptible_sleep_on race Date: Thu, 2 Jan 2014 13:07:45 +0100 Message-Id: <1388664474-1710039-22-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1388664474-1710039-1-git-send-email-arnd@arndb.de> References: <1388664474-1710039-1-git-send-email-arnd@arndb.de> X-Provags-ID: V02:K0:YRlAxqwQaZrpkMASaYPro7rblmZQa+1ar0y5ujwzKCA zmboknNpwAsRApXxBGaosWlgPiTVadIzJZk0WecKcFf1RByH0f 7LSqMNAWWR+AmVAbnPAC2x5v1O58NV7PptNUYmGqHQx8dSorGl Pz1kIVtu/NstGbMDXDkJJbBP2QyLy6tLuCDIl9AoXsclwRwKh5 gIVRIkxt0OQKk/kyxFhzCvmMZ3YFT5JXgVPUL1Hubqs4IfUEhP DREEWbimEOcEZzOZmlfK81DR0zZRld45nlHw7awkrh6GAo72av K6zV4jtyVucuxmC80nOuyqwM/B62d2vxGN4RuHdGzti6eRAZ9K Jbi9DA2EqPBawsAPBcoFQl51T5U1jdfADeP0RDYW3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2580 Lines: 70 These two drivers use identical code for their procfs status file handling, which contains a small race against status data becoming available while reading the file. This uses wait_event_interruptible instead to fix this particular race and eventually get rid of all sleep_on instances. There seems to be another race involving multiple concurrent readers of the same procfs file, which I don't try to fix here. Signed-off-by: Arnd Bergmann Cc: Karsten Keil Cc: netdev@vger.kernel.org --- drivers/isdn/divert/divert_procfs.c | 7 ++++--- drivers/isdn/hysdn/hysdn_proclog.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c index fb4f1ba..1c5dc34 100644 --- a/drivers/isdn/divert/divert_procfs.c +++ b/drivers/isdn/divert/divert_procfs.c @@ -86,12 +86,13 @@ isdn_divert_read(struct file *file, char __user *buf, size_t count, loff_t *off) struct divert_info *inf; int len; - if (!*((struct divert_info **) file->private_data)) { + if (!(inf = *((struct divert_info **) file->private_data))) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; - interruptible_sleep_on(&(rd_queue)); + wait_event_interruptible(rd_queue, (inf = + *((struct divert_info **) file->private_data))); } - if (!(inf = *((struct divert_info **) file->private_data))) + if (!inf) return (0); inf->usage_cnt--; /* new usage count */ diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c index b61e8d5..7b5fd8f 100644 --- a/drivers/isdn/hysdn/hysdn_proclog.c +++ b/drivers/isdn/hysdn/hysdn_proclog.c @@ -175,14 +175,15 @@ hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t *off) int len; hysdn_card *card = PDE_DATA(file_inode(file)); - if (!*((struct log_data **) file->private_data)) { + if (!(inf = *((struct log_data **) file->private_data))) { struct procdata *pd = card->proclog; if (file->f_flags & O_NONBLOCK) return (-EAGAIN); - interruptible_sleep_on(&(pd->rd_queue)); + wait_event_interruptible(pd->rd_queue, (inf = + *((struct log_data **) file->private_data))); } - if (!(inf = *((struct log_data **) file->private_data))) + if (!inf) return (0); inf->usage_cnt--; /* new usage count */ -- 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/