Skip to content

Commit 233e70f

Browse files
Al Virotorvalds
authored andcommitted
saner FASYNC handling on file close
As it is, all instances of ->release() for files that have ->fasync() need to remember to evict file from fasync lists; forgetting that creates a hole and we actually have a bunch that *does* forget. So let's keep our lives simple - let __fput() check FASYNC in file->f_flags and call ->fasync() there if it's been set. And lose that crap in ->release() instances - leaving it there is still valid, but we don't have to bother anymore. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3318a38 commit 233e70f

36 files changed

Lines changed: 13 additions & 109 deletions

File tree

‎arch/ia64/kernel/perfmon.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,11 +1995,6 @@ pfm_close(struct inode *inode, struct file *filp)
19951995
return -EBADF;
19961996
}
19971997

1998-
if (filp->f_flags & FASYNC) {
1999-
DPRINT(("cleaning up async_queue=%p\n", ctx->ctx_async_queue));
2000-
pfm_do_fasync(-1, filp, ctx, 0);
2001-
}
2002-
20031998
PROTECT_CTX(ctx, flags);
20041999

20052000
state = ctx->ctx_state;

‎drivers/char/hpet.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,6 @@ static int hpet_release(struct inode *inode, struct file *file)
427427
if (irq)
428428
free_irq(irq, devp);
429429

430-
if (file->f_flags & FASYNC)
431-
hpet_fasync(-1, file, 0);
432-
433430
file->private_data = NULL;
434431
return 0;
435432
}

‎drivers/char/ipmi/ipmi_devintf.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ static int ipmi_release(struct inode *inode, struct file *file)
162162
if (rv)
163163
return rv;
164164

165-
ipmi_fasync (-1, file, 0);
166-
167165
/* FIXME - free the messages in the list. */
168166
kfree(priv);
169167

‎drivers/char/ipmi/ipmi_watchdog.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,6 @@ static int ipmi_close(struct inode *ino, struct file *filep)
870870
clear_bit(0, &ipmi_wdog_open);
871871
}
872872

873-
ipmi_fasync(-1, filep, 0);
874873
expect_close = 0;
875874

876875
return 0;

‎drivers/char/random.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,26 +1139,19 @@ static int random_fasync(int fd, struct file *filp, int on)
11391139
return fasync_helper(fd, filp, on, &fasync);
11401140
}
11411141

1142-
static int random_release(struct inode *inode, struct file *filp)
1143-
{
1144-
return fasync_helper(-1, filp, 0, &fasync);
1145-
}
1146-
11471142
const struct file_operations random_fops = {
11481143
.read = random_read,
11491144
.write = random_write,
11501145
.poll = random_poll,
11511146
.unlocked_ioctl = random_ioctl,
11521147
.fasync = random_fasync,
1153-
.release = random_release,
11541148
};
11551149

11561150
const struct file_operations urandom_fops = {
11571151
.read = urandom_read,
11581152
.write = random_write,
11591153
.unlocked_ioctl = random_ioctl,
11601154
.fasync = random_fasync,
1161-
.release = random_release,
11621155
};
11631156

11641157
/***************************************************************

‎drivers/char/rtc.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,6 @@ static int rtc_release(struct inode *inode, struct file *file)
788788
}
789789
spin_unlock_irq(&rtc_lock);
790790

791-
if (file->f_flags & FASYNC)
792-
rtc_fasync(-1, file, 0);
793791
no_irq:
794792
#endif
795793

‎drivers/char/sonypi.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,6 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
898898

899899
static int sonypi_misc_release(struct inode *inode, struct file *file)
900900
{
901-
sonypi_misc_fasync(-1, file, 0);
902901
mutex_lock(&sonypi_device.lock);
903902
sonypi_device.open_count--;
904903
mutex_unlock(&sonypi_device.lock);

‎drivers/gpu/drm/drm_fops.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,6 @@ int drm_release(struct inode *inode, struct file *filp)
406406
if (dev->driver->driver_features & DRIVER_GEM)
407407
drm_gem_release(dev, file_priv);
408408

409-
drm_fasync(-1, filp, 0);
410-
411409
mutex_lock(&dev->ctxlist_mutex);
412410
if (!list_empty(&dev->ctxlist)) {
413411
struct drm_ctx_list *pos, *n;

‎drivers/hid/usbhid/hiddev.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ static int hiddev_release(struct inode * inode, struct file * file)
242242
struct hiddev_list *list = file->private_data;
243243
unsigned long flags;
244244

245-
hiddev_fasync(-1, file, 0);
246-
247245
spin_lock_irqsave(&list->hiddev->list_lock, flags);
248246
list_del(&list->node);
249247
spin_unlock_irqrestore(&list->hiddev->list_lock, flags);

‎drivers/ieee1394/dv1394.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,9 +1828,6 @@ static int dv1394_release(struct inode *inode, struct file *file)
18281828
/* OK to free the DMA buffer, no more mappings can exist */
18291829
do_dv1394_shutdown(video, 1);
18301830

1831-
/* clean up async I/O users */
1832-
dv1394_fasync(-1, file, 0);
1833-
18341831
/* give someone else a turn */
18351832
clear_bit(0, &video->open);
18361833

0 commit comments

Comments
 (0)