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>
This commit is contained in:
@@ -427,9 +427,6 @@ static int hpet_release(struct inode *inode, struct file *file)
|
||||
if (irq)
|
||||
free_irq(irq, devp);
|
||||
|
||||
if (file->f_flags & FASYNC)
|
||||
hpet_fasync(-1, file, 0);
|
||||
|
||||
file->private_data = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -162,8 +162,6 @@ static int ipmi_release(struct inode *inode, struct file *file)
|
||||
if (rv)
|
||||
return rv;
|
||||
|
||||
ipmi_fasync (-1, file, 0);
|
||||
|
||||
/* FIXME - free the messages in the list. */
|
||||
kfree(priv);
|
||||
|
||||
|
||||
@@ -870,7 +870,6 @@ static int ipmi_close(struct inode *ino, struct file *filep)
|
||||
clear_bit(0, &ipmi_wdog_open);
|
||||
}
|
||||
|
||||
ipmi_fasync(-1, filep, 0);
|
||||
expect_close = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1139,18 +1139,12 @@ static int random_fasync(int fd, struct file *filp, int on)
|
||||
return fasync_helper(fd, filp, on, &fasync);
|
||||
}
|
||||
|
||||
static int random_release(struct inode *inode, struct file *filp)
|
||||
{
|
||||
return fasync_helper(-1, filp, 0, &fasync);
|
||||
}
|
||||
|
||||
const struct file_operations random_fops = {
|
||||
.read = random_read,
|
||||
.write = random_write,
|
||||
.poll = random_poll,
|
||||
.unlocked_ioctl = random_ioctl,
|
||||
.fasync = random_fasync,
|
||||
.release = random_release,
|
||||
};
|
||||
|
||||
const struct file_operations urandom_fops = {
|
||||
@@ -1158,7 +1152,6 @@ const struct file_operations urandom_fops = {
|
||||
.write = random_write,
|
||||
.unlocked_ioctl = random_ioctl,
|
||||
.fasync = random_fasync,
|
||||
.release = random_release,
|
||||
};
|
||||
|
||||
/***************************************************************
|
||||
|
||||
@@ -788,8 +788,6 @@ static int rtc_release(struct inode *inode, struct file *file)
|
||||
}
|
||||
spin_unlock_irq(&rtc_lock);
|
||||
|
||||
if (file->f_flags & FASYNC)
|
||||
rtc_fasync(-1, file, 0);
|
||||
no_irq:
|
||||
#endif
|
||||
|
||||
|
||||
@@ -898,7 +898,6 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
|
||||
|
||||
static int sonypi_misc_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
sonypi_misc_fasync(-1, file, 0);
|
||||
mutex_lock(&sonypi_device.lock);
|
||||
sonypi_device.open_count--;
|
||||
mutex_unlock(&sonypi_device.lock);
|
||||
|
||||
Reference in New Issue
Block a user