aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2008-10-31 19:28:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-11-01 12:49:46 -0400
commit233e70f4228e78eb2f80dc6650f65d3ae3dbf17c (patch)
tree4e18fbe1851e6d2161b7f18265cb21f8a61e3ce7
parent3318a386e4ca68c76e0294363d29bdc46fcad670 (diff)
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>
-rw-r--r--arch/ia64/kernel/perfmon.c5
-rw-r--r--drivers/char/hpet.c3
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c2
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c1
-rw-r--r--drivers/char/random.c7
-rw-r--r--drivers/char/rtc.c2
-rw-r--r--drivers/char/sonypi.c1
-rw-r--r--drivers/gpu/drm/drm_fops.c2
-rw-r--r--drivers/hid/usbhid/hiddev.c2
-rw-r--r--drivers/ieee1394/dv1394.c3
-rw-r--r--drivers/infiniband/core/uverbs_main.c2
-rw-r--r--drivers/input/evdev.c1
-rw-r--r--drivers/input/joydev.c1
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c13
-rw-r--r--drivers/input/mousedev.c1
-rw-r--r--drivers/input/serio/serio_raw.c1
-rw-r--r--drivers/message/fusion/mptctl.c7
-rw-r--r--drivers/message/i2o/i2o_config.c21
-rw-r--r--drivers/misc/sony-laptop.c1
-rw-r--r--drivers/net/tun.c2
-rw-r--r--drivers/rtc/rtc-dev.c3
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c12
-rw-r--r--drivers/scsi/sg.c1
-rw-r--r--drivers/staging/me4000/me4000.c3
-rw-r--r--drivers/telephony/ixj.c1
-rw-r--r--drivers/uio/uio.c3
-rw-r--r--drivers/usb/gadget/inode.c1
-rw-r--r--fs/file_table.c4
-rw-r--r--fs/fuse/dev.c1
-rw-r--r--fs/inotify_user.c3
-rw-r--r--fs/pipe.c3
-rw-r--r--net/socket.c1
-rw-r--r--sound/core/control.c1
-rw-r--r--sound/core/init.c5
-rw-r--r--sound/core/pcm_native.c1
-rw-r--r--sound/core/timer.c1
36 files changed, 13 insertions, 109 deletions
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index ada4605d1223..6543a5547c84 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -1995,11 +1995,6 @@ pfm_close(struct inode *inode, struct file *filp)
1995 return -EBADF; 1995 return -EBADF;
1996 } 1996 }
1997 1997
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
2003 PROTECT_CTX(ctx, flags); 1998 PROTECT_CTX(ctx, flags);
2004 1999
2005 state = ctx->ctx_state; 2000 state = ctx->ctx_state;
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 408f5f92cb4e..53fdc7ff3870 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -427,9 +427,6 @@ static int hpet_release(struct inode *inode, struct file *file)
427 if (irq) 427 if (irq)
428 free_irq(irq, devp); 428 free_irq(irq, devp);
429 429
430 if (file->f_flags & FASYNC)
431 hpet_fasync(-1, file, 0);
432
433 file->private_data = NULL; 430 file->private_data = NULL;
434 return 0; 431 return 0;
435} 432}
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 1d7b429f7ffa..41fc11dc921c 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -162,8 +162,6 @@ static int ipmi_release(struct inode *inode, struct file *file)
162 if (rv) 162 if (rv)
163 return rv; 163 return rv;
164 164
165 ipmi_fasync (-1, file, 0);
166
167 /* FIXME - free the messages in the list. */ 165 /* FIXME - free the messages in the list. */
168 kfree(priv); 166 kfree(priv);
169 167
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 235fab0bdf79..a4d57e31f713 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -870,7 +870,6 @@ static int ipmi_close(struct inode *ino, struct file *filep)
870 clear_bit(0, &ipmi_wdog_open); 870 clear_bit(0, &ipmi_wdog_open);
871 } 871 }
872 872
873 ipmi_fasync(-1, filep, 0);
874 expect_close = 0; 873 expect_close = 0;
875 874
876 return 0; 875 return 0;
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 705a839f1796..675076f5fca8 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1139,18 +1139,12 @@ static int random_fasync(int fd, struct file *filp, int on)
1139 return fasync_helper(fd, filp, on, &fasync); 1139 return fasync_helper(fd, filp, on, &fasync);
1140} 1140}
1141 1141
1142static int random_release(struct inode *inode, struct file *filp)
1143{
1144 return fasync_helper(-1, filp, 0, &fasync);
1145}
1146
1147const struct file_operations random_fops = { 1142const struct file_operations random_fops = {
1148 .read = random_read, 1143 .read = random_read,
1149 .write = random_write, 1144 .write = random_write,
1150 .poll = random_poll, 1145 .poll = random_poll,
1151 .unlocked_ioctl = random_ioctl, 1146 .unlocked_ioctl = random_ioctl,
1152 .fasync = random_fasync, 1147 .fasync = random_fasync,
1153 .release = random_release,
1154}; 1148};
1155 1149
1156const struct file_operations urandom_fops = { 1150const struct file_operations urandom_fops = {
@@ -1158,7 +1152,6 @@ const struct file_operations urandom_fops = {
1158 .write = random_write, 1152 .write = random_write,
1159 .unlocked_ioctl = random_ioctl, 1153 .unlocked_ioctl = random_ioctl,
1160 .fasync = random_fasync, 1154 .fasync = random_fasync,
1161 .release = random_release,
1162}; 1155};
1163 1156
1164/*************************************************************** 1157/***************************************************************
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 32dc89720d58..20d6efb6324e 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -788,8 +788,6 @@ static int rtc_release(struct inode *inode, struct file *file)
788 } 788 }
789 spin_unlock_irq(&rtc_lock); 789 spin_unlock_irq(&rtc_lock);
790 790
791 if (file->f_flags & FASYNC)
792 rtc_fasync(-1, file, 0);
793no_irq: 791no_irq:
794#endif 792#endif
795 793
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 85e0eb76eeab..2457b07dabd6 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -898,7 +898,6 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
898 898
899static int sonypi_misc_release(struct inode *inode, struct file *file) 899static int sonypi_misc_release(struct inode *inode, struct file *file)
900{ 900{
901 sonypi_misc_fasync(-1, file, 0);
902 mutex_lock(&sonypi_device.lock); 901 mutex_lock(&sonypi_device.lock);
903 sonypi_device.open_count--; 902 sonypi_device.open_count--;
904 mutex_unlock(&sonypi_device.lock); 903 mutex_unlock(&sonypi_device.lock);
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 0d46627663b1..78eeed5caaff 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -406,8 +406,6 @@ int drm_release(struct inode *inode, struct file *filp)
406 if (dev->driver->driver_features & DRIVER_GEM) 406 if (dev->driver->driver_features & DRIVER_GEM)
407 drm_gem_release(dev, file_priv); 407 drm_gem_release(dev, file_priv);
408 408
409 drm_fasync(-1, filp, 0);
410
411 mutex_lock(&dev->ctxlist_mutex); 409 mutex_lock(&dev->ctxlist_mutex);
412 if (!list_empty(&dev->ctxlist)) { 410 if (!list_empty(&dev->ctxlist)) {
413 struct drm_ctx_list *pos, *n; 411 struct drm_ctx_list *pos, *n;
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 3ac320785fc5..83e851a5ed30 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -242,8 +242,6 @@ static int hiddev_release(struct inode * inode, struct file * file)
242 struct hiddev_list *list = file->private_data; 242 struct hiddev_list *list = file->private_data;
243 unsigned long flags; 243 unsigned long flags;
244 244
245 hiddev_fasync(-1, file, 0);
246
247 spin_lock_irqsave(&list->hiddev->list_lock, flags); 245 spin_lock_irqsave(&list->hiddev->list_lock, flags);
248 list_del(&list->node); 246 list_del(&list->node);
249 spin_unlock_irqrestore(&list->hiddev->list_lock, flags); 247 spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index 2f83543a9dfc..965cfdb84ebc 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -1828,9 +1828,6 @@ static int dv1394_release(struct inode *inode, struct file *file)
1828 /* OK to free the DMA buffer, no more mappings can exist */ 1828 /* OK to free the DMA buffer, no more mappings can exist */
1829 do_dv1394_shutdown(video, 1); 1829 do_dv1394_shutdown(video, 1);
1830 1830
1831 /* clean up async I/O users */
1832 dv1394_fasync(-1, file, 0);
1833
1834 /* give someone else a turn */ 1831 /* give someone else a turn */
1835 clear_bit(0, &video->open); 1832 clear_bit(0, &video->open);
1836 1833
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index d85af1b67027..eb36a81dd09b 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -358,8 +358,6 @@ static int ib_uverbs_event_close(struct inode *inode, struct file *filp)
358 } 358 }
359 spin_unlock_irq(&file->lock); 359 spin_unlock_irq(&file->lock);
360 360
361 ib_uverbs_event_fasync(-1, filp, 0);
362
363 if (file->is_async) { 361 if (file->is_async) {
364 ib_unregister_event_handler(&file->uverbs_file->event_handler); 362 ib_unregister_event_handler(&file->uverbs_file->event_handler);
365 kref_put(&file->uverbs_file->ref, ib_uverbs_release_file); 363 kref_put(&file->uverbs_file->ref, ib_uverbs_release_file);
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 3524bef62be6..1070db330d35 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -235,7 +235,6 @@ static int evdev_release(struct inode *inode, struct file *file)
235 evdev_ungrab(evdev, client); 235 evdev_ungrab(evdev, client);
236 mutex_unlock(&evdev->mutex); 236 mutex_unlock(&evdev->mutex);
237 237
238 evdev_fasync(-1, file, 0);
239 evdev_detach_client(evdev, client); 238 evdev_detach_client(evdev, client);
240 kfree(client); 239 kfree(client);
241 240
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 65d7077a75a1..a85b1485e774 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -244,7 +244,6 @@ static int joydev_release(struct inode *inode, struct file *file)
244 struct joydev_client *client = file->private_data; 244 struct joydev_client *client = file->private_data;
245 struct joydev *joydev = client->joydev; 245 struct joydev *joydev = client->joydev;
246 246
247 joydev_fasync(-1, file, 0);
248 joydev_detach_client(joydev, client); 247 joydev_detach_client(joydev, client);
249 kfree(client); 248 kfree(client);
250 249
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index 82ec6b1b6467..216a559f55ea 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -71,7 +71,6 @@ static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
71static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait); 71static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait);
72 72
73static int hp_sdc_rtc_open(struct inode *inode, struct file *file); 73static int hp_sdc_rtc_open(struct inode *inode, struct file *file);
74static int hp_sdc_rtc_release(struct inode *inode, struct file *file);
75static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on); 74static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on);
76 75
77static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off, 76static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off,
@@ -414,17 +413,6 @@ static int hp_sdc_rtc_open(struct inode *inode, struct file *file)
414 return 0; 413 return 0;
415} 414}
416 415
417static int hp_sdc_rtc_release(struct inode *inode, struct file *file)
418{
419 /* Turn off interrupts? */
420
421 if (file->f_flags & FASYNC) {
422 hp_sdc_rtc_fasync (-1, file, 0);
423 }
424
425 return 0;
426}
427
428static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on) 416static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on)
429{ 417{
430 return fasync_helper (fd, filp, on, &hp_sdc_rtc_async_queue); 418 return fasync_helper (fd, filp, on, &hp_sdc_rtc_async_queue);
@@ -680,7 +668,6 @@ static const struct file_operations hp_sdc_rtc_fops = {
680 .poll = hp_sdc_rtc_poll, 668 .poll = hp_sdc_rtc_poll,
681 .ioctl = hp_sdc_rtc_ioctl, 669 .ioctl = hp_sdc_rtc_ioctl,
682 .open = hp_sdc_rtc_open, 670 .open = hp_sdc_rtc_open,
683 .release = hp_sdc_rtc_release,
684 .fasync = hp_sdc_rtc_fasync, 671 .fasync = hp_sdc_rtc_fasync,
685}; 672};
686 673
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 8137e50ded87..d8c056fe7e98 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -519,7 +519,6 @@ static int mousedev_release(struct inode *inode, struct file *file)
519 struct mousedev_client *client = file->private_data; 519 struct mousedev_client *client = file->private_data;
520 struct mousedev *mousedev = client->mousedev; 520 struct mousedev *mousedev = client->mousedev;
521 521
522 mousedev_fasync(-1, file, 0);
523 mousedev_detach_client(mousedev, client); 522 mousedev_detach_client(mousedev, client);
524 kfree(client); 523 kfree(client);
525 524
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 470770c09260..06bbd0e74c6f 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -135,7 +135,6 @@ static int serio_raw_release(struct inode *inode, struct file *file)
135 135
136 mutex_lock(&serio_raw_mutex); 136 mutex_lock(&serio_raw_mutex);
137 137
138 serio_raw_fasync(-1, file, 0);
139 serio_raw_cleanup(serio_raw); 138 serio_raw_cleanup(serio_raw);
140 139
141 mutex_unlock(&serio_raw_mutex); 140 mutex_unlock(&serio_raw_mutex);
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index f5233f3d9eff..b89f476cd0a9 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -559,12 +559,6 @@ mptctl_fasync(int fd, struct file *filep, int mode)
559 return ret; 559 return ret;
560} 560}
561 561
562static int
563mptctl_release(struct inode *inode, struct file *filep)
564{
565 return fasync_helper(-1, filep, 0, &async_queue);
566}
567
568/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 562/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
569/* 563/*
570 * MPT ioctl handler 564 * MPT ioctl handler
@@ -2706,7 +2700,6 @@ mptctl_hp_targetinfo(unsigned long arg)
2706static const struct file_operations mptctl_fops = { 2700static const struct file_operations mptctl_fops = {
2707 .owner = THIS_MODULE, 2701 .owner = THIS_MODULE,
2708 .llseek = no_llseek, 2702 .llseek = no_llseek,
2709 .release = mptctl_release,
2710 .fasync = mptctl_fasync, 2703 .fasync = mptctl_fasync,
2711 .unlocked_ioctl = mptctl_ioctl, 2704 .unlocked_ioctl = mptctl_ioctl,
2712#ifdef CONFIG_COMPAT 2705#ifdef CONFIG_COMPAT
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index a3fabdbe6ca6..f3384c32b9a1 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -1097,28 +1097,17 @@ static int cfg_fasync(int fd, struct file *fp, int on)
1097static int cfg_release(struct inode *inode, struct file *file) 1097static int cfg_release(struct inode *inode, struct file *file)
1098{ 1098{
1099 ulong id = (ulong) file->private_data; 1099 ulong id = (ulong) file->private_data;
1100 struct i2o_cfg_info *p1, *p2; 1100 struct i2o_cfg_info *p, **q;
1101 unsigned long flags; 1101 unsigned long flags;
1102 1102
1103 lock_kernel(); 1103 lock_kernel();
1104 p1 = p2 = NULL;
1105
1106 spin_lock_irqsave(&i2o_config_lock, flags); 1104 spin_lock_irqsave(&i2o_config_lock, flags);
1107 for (p1 = open_files; p1;) { 1105 for (q = &open_files; (p = *q) != NULL; q = &p->next) {
1108 if (p1->q_id == id) { 1106 if (p->q_id == id) {
1109 1107 *q = p->next;
1110 if (p1->fasync) 1108 kfree(p);
1111 cfg_fasync(-1, file, 0);
1112 if (p2)
1113 p2->next = p1->next;
1114 else
1115 open_files = p1->next;
1116
1117 kfree(p1);
1118 break; 1109 break;
1119 } 1110 }
1120 p2 = p1;
1121 p1 = p1->next;
1122 } 1111 }
1123 spin_unlock_irqrestore(&i2o_config_lock, flags); 1112 spin_unlock_irqrestore(&i2o_config_lock, flags);
1124 unlock_kernel(); 1113 unlock_kernel();
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index f483c4221f76..06f07e19dc70 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -1920,7 +1920,6 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
1920 1920
1921static int sonypi_misc_release(struct inode *inode, struct file *file) 1921static int sonypi_misc_release(struct inode *inode, struct file *file)
1922{ 1922{
1923 sonypi_misc_fasync(-1, file, 0);
1924 atomic_dec(&sonypi_compat.open_count); 1923 atomic_dec(&sonypi_compat.open_count);
1925 return 0; 1924 return 0;
1926} 1925}
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 6daea0c91862..33b6d1b122fb 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1070,8 +1070,6 @@ static int tun_chr_close(struct inode *inode, struct file *file)
1070 1070
1071 DBG(KERN_INFO "%s: tun_chr_close\n", tun->dev->name); 1071 DBG(KERN_INFO "%s: tun_chr_close\n", tun->dev->name);
1072 1072
1073 tun_chr_fasync(-1, file, 0);
1074
1075 rtnl_lock(); 1073 rtnl_lock();
1076 1074
1077 /* Detach from net device */ 1075 /* Detach from net device */
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 079e9ed907e0..ecdea44ae4e5 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -446,9 +446,6 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
446 if (rtc->ops->release) 446 if (rtc->ops->release)
447 rtc->ops->release(rtc->dev.parent); 447 rtc->ops->release(rtc->dev.parent);
448 448
449 if (file->f_flags & FASYNC)
450 rtc_dev_fasync(-1, file, 0);
451
452 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags); 449 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
453 return 0; 450 return 0;
454} 451}
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index afe1de998763..a454f94623d7 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -2988,17 +2988,6 @@ static int megasas_mgmt_open(struct inode *inode, struct file *filep)
2988} 2988}
2989 2989
2990/** 2990/**
2991 * megasas_mgmt_release - char node "release" entry point
2992 */
2993static int megasas_mgmt_release(struct inode *inode, struct file *filep)
2994{
2995 filep->private_data = NULL;
2996 fasync_helper(-1, filep, 0, &megasas_async_queue);
2997
2998 return 0;
2999}
3000
3001/**
3002 * megasas_mgmt_fasync - Async notifier registration from applications 2991 * megasas_mgmt_fasync - Async notifier registration from applications
3003 * 2992 *
3004 * This function adds the calling process to a driver global queue. When an 2993 * This function adds the calling process to a driver global queue. When an
@@ -3345,7 +3334,6 @@ megasas_mgmt_compat_ioctl(struct file *file, unsigned int cmd,
3345static const struct file_operations megasas_mgmt_fops = { 3334static const struct file_operations megasas_mgmt_fops = {
3346 .owner = THIS_MODULE, 3335 .owner = THIS_MODULE,
3347 .open = megasas_mgmt_open, 3336 .open = megasas_mgmt_open,
3348 .release = megasas_mgmt_release,
3349 .fasync = megasas_mgmt_fasync, 3337 .fasync = megasas_mgmt_fasync,
3350 .unlocked_ioctl = megasas_mgmt_ioctl, 3338 .unlocked_ioctl = megasas_mgmt_ioctl,
3351#ifdef CONFIG_COMPAT 3339#ifdef CONFIG_COMPAT
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 9adf35bd8b56..5103855242ae 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -327,7 +327,6 @@ sg_release(struct inode *inode, struct file *filp)
327 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) 327 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
328 return -ENXIO; 328 return -ENXIO;
329 SCSI_LOG_TIMEOUT(3, printk("sg_release: %s\n", sdp->disk->disk_name)); 329 SCSI_LOG_TIMEOUT(3, printk("sg_release: %s\n", sdp->disk->disk_name));
330 sg_fasync(-1, filp, 0); /* remove filp from async notification list */
331 if (0 == sg_remove_sfp(sdp, sfp)) { /* Returns 1 when sdp gone */ 330 if (0 == sg_remove_sfp(sdp, sfp)) { /* Returns 1 when sdp gone */
332 if (!sdp->detached) { 331 if (!sdp->detached) {
333 scsi_device_put(sdp->device); 332 scsi_device_put(sdp->device);
diff --git a/drivers/staging/me4000/me4000.c b/drivers/staging/me4000/me4000.c
index 0b33773bb4f6..cf8b01bcac8d 100644
--- a/drivers/staging/me4000/me4000.c
+++ b/drivers/staging/me4000/me4000.c
@@ -1633,9 +1633,6 @@ static int me4000_release(struct inode *inode_p, struct file *file_p)
1633 1633
1634 free_irq(ext_int_context->irq, ext_int_context); 1634 free_irq(ext_int_context->irq, ext_int_context);
1635 1635
1636 /* Delete the fasync structure and free memory */
1637 me4000_ext_int_fasync(0, file_p, 0);
1638
1639 /* Mark as unused */ 1636 /* Mark as unused */
1640 ext_int_context->in_use = 0; 1637 ext_int_context->in_use = 0;
1641 } else { 1638 } else {
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index 41b6530b8f25..a913efc69669 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -2328,7 +2328,6 @@ static int ixj_release(struct inode *inode, struct file *file_p)
2328 j->rec_codec = j->play_codec = 0; 2328 j->rec_codec = j->play_codec = 0;
2329 j->rec_frame_size = j->play_frame_size = 0; 2329 j->rec_frame_size = j->play_frame_size = 0;
2330 j->flags.cidsent = j->flags.cidring = 0; 2330 j->flags.cidsent = j->flags.cidring = 0;
2331 ixj_fasync(-1, file_p, 0); /* remove from list of async notification */
2332 2331
2333 if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) { 2332 if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) {
2334 ixj_set_port(j, PORT_PSTN); 2333 ixj_set_port(j, PORT_PSTN);
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index f9b4647255aa..2d2440cd57a9 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -367,9 +367,6 @@ static int uio_release(struct inode *inode, struct file *filep)
367 ret = idev->info->release(idev->info, inode); 367 ret = idev->info->release(idev->info, inode);
368 368
369 module_put(idev->owner); 369 module_put(idev->owner);
370
371 if (filep->f_flags & FASYNC)
372 ret = uio_fasync(-1, filep, 0);
373 kfree(listener); 370 kfree(listener);
374 return ret; 371 return ret;
375} 372}
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index f4585d3e90d7..eeb26c0f88e5 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1251,7 +1251,6 @@ dev_release (struct inode *inode, struct file *fd)
1251 * alternatively, all host requests will time out. 1251 * alternatively, all host requests will time out.
1252 */ 1252 */
1253 1253
1254 fasync_helper (-1, fd, 0, &dev->fasync);
1255 kfree (dev->buf); 1254 kfree (dev->buf);
1256 dev->buf = NULL; 1255 dev->buf = NULL;
1257 put_dev (dev); 1256 put_dev (dev);
diff --git a/fs/file_table.c b/fs/file_table.c
index efc06faede6c..5ad0eca6eea2 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -269,6 +269,10 @@ void __fput(struct file *file)
269 eventpoll_release(file); 269 eventpoll_release(file);
270 locks_remove_flock(file); 270 locks_remove_flock(file);
271 271
272 if (unlikely(file->f_flags & FASYNC)) {
273 if (file->f_op && file->f_op->fasync)
274 file->f_op->fasync(-1, file, 0);
275 }
272 if (file->f_op && file->f_op->release) 276 if (file->f_op && file->f_op->release)
273 file->f_op->release(inode, file); 277 file->f_op->release(inode, file);
274 security_file_free(file); 278 security_file_free(file);
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 87250b6a8682..b72361479be2 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1056,7 +1056,6 @@ static int fuse_dev_release(struct inode *inode, struct file *file)
1056 end_requests(fc, &fc->pending); 1056 end_requests(fc, &fc->pending);
1057 end_requests(fc, &fc->processing); 1057 end_requests(fc, &fc->processing);
1058 spin_unlock(&fc->lock); 1058 spin_unlock(&fc->lock);
1059 fasync_helper(-1, file, 0, &fc->fasync);
1060 fuse_conn_put(fc); 1059 fuse_conn_put(fc);
1061 } 1060 }
1062 1061
diff --git a/fs/inotify_user.c b/fs/inotify_user.c
index d85c7d931cdf..d367e9b92862 100644
--- a/fs/inotify_user.c
+++ b/fs/inotify_user.c
@@ -537,9 +537,6 @@ static int inotify_release(struct inode *ignored, struct file *file)
537 inotify_dev_event_dequeue(dev); 537 inotify_dev_event_dequeue(dev);
538 mutex_unlock(&dev->ev_mutex); 538 mutex_unlock(&dev->ev_mutex);
539 539
540 if (file->f_flags & FASYNC)
541 inotify_fasync(-1, file, 0);
542
543 /* free this device: the put matching the get in inotify_init() */ 540 /* free this device: the put matching the get in inotify_init() */
544 put_inotify_dev(dev); 541 put_inotify_dev(dev);
545 542
diff --git a/fs/pipe.c b/fs/pipe.c
index fcba6542b8d0..7aea8b89baac 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -717,14 +717,12 @@ pipe_rdwr_fasync(int fd, struct file *filp, int on)
717static int 717static int
718pipe_read_release(struct inode *inode, struct file *filp) 718pipe_read_release(struct inode *inode, struct file *filp)
719{ 719{
720 pipe_read_fasync(-1, filp, 0);
721 return pipe_release(inode, 1, 0); 720 return pipe_release(inode, 1, 0);
722} 721}
723 722
724static int 723static int
725pipe_write_release(struct inode *inode, struct file *filp) 724pipe_write_release(struct inode *inode, struct file *filp)
726{ 725{
727 pipe_write_fasync(-1, filp, 0);
728 return pipe_release(inode, 0, 1); 726 return pipe_release(inode, 0, 1);
729} 727}
730 728
@@ -733,7 +731,6 @@ pipe_rdwr_release(struct inode *inode, struct file *filp)
733{ 731{
734 int decr, decw; 732 int decr, decw;
735 733
736 pipe_rdwr_fasync(-1, filp, 0);
737 decr = (filp->f_mode & FMODE_READ) != 0; 734 decr = (filp->f_mode & FMODE_READ) != 0;
738 decw = (filp->f_mode & FMODE_WRITE) != 0; 735 decw = (filp->f_mode & FMODE_WRITE) != 0;
739 return pipe_release(inode, decr, decw); 736 return pipe_release(inode, decr, decw);
diff --git a/net/socket.c b/net/socket.c
index 2b7a4b5c9b72..57550c3bcabe 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -990,7 +990,6 @@ static int sock_close(struct inode *inode, struct file *filp)
990 printk(KERN_DEBUG "sock_close: NULL inode\n"); 990 printk(KERN_DEBUG "sock_close: NULL inode\n");
991 return 0; 991 return 0;
992 } 992 }
993 sock_fasync(-1, filp, 0);
994 sock_release(SOCKET_I(inode)); 993 sock_release(SOCKET_I(inode));
995 return 0; 994 return 0;
996} 995}
diff --git a/sound/core/control.c b/sound/core/control.c
index b0bf42691047..636b3b52ef8b 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -113,7 +113,6 @@ static int snd_ctl_release(struct inode *inode, struct file *file)
113 unsigned int idx; 113 unsigned int idx;
114 114
115 ctl = file->private_data; 115 ctl = file->private_data;
116 fasync_helper(-1, file, 0, &ctl->fasync);
117 file->private_data = NULL; 116 file->private_data = NULL;
118 card = ctl->card; 117 card = ctl->card;
119 write_lock_irqsave(&card->ctl_files_rwlock, flags); 118 write_lock_irqsave(&card->ctl_files_rwlock, flags);
diff --git a/sound/core/init.c b/sound/core/init.c
index ef2352c2e451..b47ff8b44be8 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -264,8 +264,11 @@ static int snd_disconnect_release(struct inode *inode, struct file *file)
264 } 264 }
265 spin_unlock(&shutdown_lock); 265 spin_unlock(&shutdown_lock);
266 266
267 if (likely(df)) 267 if (likely(df)) {
268 if ((file->f_flags & FASYNC) && df->disconnected_f_op->fasync)
269 df->disconnected_f_op->fasync(-1, file, 0);
268 return df->disconnected_f_op->release(inode, file); 270 return df->disconnected_f_op->release(inode, file);
271 }
269 272
270 panic("%s(%p, %p) failed!", __func__, inode, file); 273 panic("%s(%p, %p) failed!", __func__, inode, file);
271} 274}
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index aef18682c035..a789efc9df39 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2169,7 +2169,6 @@ static int snd_pcm_release(struct inode *inode, struct file *file)
2169 if (snd_BUG_ON(!substream)) 2169 if (snd_BUG_ON(!substream))
2170 return -ENXIO; 2170 return -ENXIO;
2171 pcm = substream->pcm; 2171 pcm = substream->pcm;
2172 fasync_helper(-1, file, 0, &substream->runtime->fasync);
2173 mutex_lock(&pcm->open_mutex); 2172 mutex_lock(&pcm->open_mutex);
2174 snd_pcm_release_substream(substream); 2173 snd_pcm_release_substream(substream);
2175 kfree(pcm_file); 2174 kfree(pcm_file);
diff --git a/sound/core/timer.c b/sound/core/timer.c
index e582face89d2..c584408c9f17 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1263,7 +1263,6 @@ static int snd_timer_user_release(struct inode *inode, struct file *file)
1263 if (file->private_data) { 1263 if (file->private_data) {
1264 tu = file->private_data; 1264 tu = file->private_data;
1265 file->private_data = NULL; 1265 file->private_data = NULL;
1266 fasync_helper(-1, file, 0, &tu->fasync);
1267 if (tu->timeri) 1266 if (tu->timeri)
1268 snd_timer_close(tu->timeri); 1267 snd_timer_close(tu->timeri);
1269 kfree(tu->queue); 1268 kfree(tu->queue);