]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
saner FASYNC handling on file close
authorAl Viro <viro@ZenIV.linux.org.uk>
Fri, 31 Oct 2008 23:28:30 +0000 (23:28 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 1 Nov 2008 16:49:46 +0000 (09:49 -0700)
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>
36 files changed:
arch/ia64/kernel/perfmon.c
drivers/char/hpet.c
drivers/char/ipmi/ipmi_devintf.c
drivers/char/ipmi/ipmi_watchdog.c
drivers/char/random.c
drivers/char/rtc.c
drivers/char/sonypi.c
drivers/gpu/drm/drm_fops.c
drivers/hid/usbhid/hiddev.c
drivers/ieee1394/dv1394.c
drivers/infiniband/core/uverbs_main.c
drivers/input/evdev.c
drivers/input/joydev.c
drivers/input/misc/hp_sdc_rtc.c
drivers/input/mousedev.c
drivers/input/serio/serio_raw.c
drivers/message/fusion/mptctl.c
drivers/message/i2o/i2o_config.c
drivers/misc/sony-laptop.c
drivers/net/tun.c
drivers/rtc/rtc-dev.c
drivers/scsi/megaraid/megaraid_sas.c
drivers/scsi/sg.c
drivers/staging/me4000/me4000.c
drivers/telephony/ixj.c
drivers/uio/uio.c
drivers/usb/gadget/inode.c
fs/file_table.c
fs/fuse/dev.c
fs/inotify_user.c
fs/pipe.c
net/socket.c
sound/core/control.c
sound/core/init.c
sound/core/pcm_native.c
sound/core/timer.c

index ada4605d12236cdf682d182b35034afd1ccf821b..6543a5547c84669434e5d4dbc3d962400a714f57 100644 (file)
@@ -1995,11 +1995,6 @@ pfm_close(struct inode *inode, struct file *filp)
                return -EBADF;
        }
 
-       if (filp->f_flags & FASYNC) {
-               DPRINT(("cleaning up async_queue=%p\n", ctx->ctx_async_queue));
-               pfm_do_fasync(-1, filp, ctx, 0);
-       }
-
        PROTECT_CTX(ctx, flags);
 
        state     = ctx->ctx_state;
index 408f5f92cb4e1f56959fae99936b34d030f67d70..53fdc7ff387051507ade9def9a75eb67ff1bfd13 100644 (file)
@@ -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;
 }
index 1d7b429f7ffaf8dd0ad262cfee1e513e4afa1ff9..41fc11dc921c70260e89551f111a8f73d97a3b10 100644 (file)
@@ -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);
 
index 235fab0bdf79d99e3bd4328c8d3a6ee42c0fb7f9..a4d57e31f713bc0c9d11f54b610ab33365e6b692 100644 (file)
@@ -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;
index 705a839f1796125b257925dc8c3aac722d992018..675076f5fca881d0ab3752b44c8356766dac1c3a 100644 (file)
@@ -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,
 };
 
 /***************************************************************
index 32dc89720d5896a6f6efebcfdfa8e8999999d85f..20d6efb6324ef4f8dc9da36eba4c77d24df0d9cd 100644 (file)
@@ -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
 
index 85e0eb76eeab92ca751ce59acfcacc38a39f61a5..2457b07dabd69a18d01acc75b257d6f88ae85a3e 100644 (file)
@@ -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);
index 0d46627663b1e93e0d50729b41162ca32c5af1a0..78eeed5caaff1ed68ed01cb2cd27a2ed156caa49 100644 (file)
@@ -406,8 +406,6 @@ int drm_release(struct inode *inode, struct file *filp)
        if (dev->driver->driver_features & DRIVER_GEM)
                drm_gem_release(dev, file_priv);
 
-       drm_fasync(-1, filp, 0);
-
        mutex_lock(&dev->ctxlist_mutex);
        if (!list_empty(&dev->ctxlist)) {
                struct drm_ctx_list *pos, *n;
index 3ac320785fc58212d38334c2a87f35b130c66a45..83e851a5ed3041f9b25bf212634f81355d0dd9f3 100644 (file)
@@ -242,8 +242,6 @@ static int hiddev_release(struct inode * inode, struct file * file)
        struct hiddev_list *list = file->private_data;
        unsigned long flags;
 
-       hiddev_fasync(-1, file, 0);
-
        spin_lock_irqsave(&list->hiddev->list_lock, flags);
        list_del(&list->node);
        spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
index 2f83543a9dfca95c797e42421055497fc1c6f2e0..965cfdb84ebc757c0c170e437be99bf637b88dbd 100644 (file)
@@ -1828,9 +1828,6 @@ static int dv1394_release(struct inode *inode, struct file *file)
        /* OK to free the DMA buffer, no more mappings can exist */
        do_dv1394_shutdown(video, 1);
 
-       /* clean up async I/O users */
-       dv1394_fasync(-1, file, 0);
-
        /* give someone else a turn */
        clear_bit(0, &video->open);
 
index d85af1b670274466f5ec13a518d8011da1cb7da0..eb36a81dd09bff2d544675de4c37c447614d3262 100644 (file)
@@ -358,8 +358,6 @@ static int ib_uverbs_event_close(struct inode *inode, struct file *filp)
        }
        spin_unlock_irq(&file->lock);
 
-       ib_uverbs_event_fasync(-1, filp, 0);
-
        if (file->is_async) {
                ib_unregister_event_handler(&file->uverbs_file->event_handler);
                kref_put(&file->uverbs_file->ref, ib_uverbs_release_file);
index 3524bef62be654910ec23ca5c917787269a6b018..1070db330d3563010668c2608c00db1c85369a1f 100644 (file)
@@ -235,7 +235,6 @@ static int evdev_release(struct inode *inode, struct file *file)
                evdev_ungrab(evdev, client);
        mutex_unlock(&evdev->mutex);
 
-       evdev_fasync(-1, file, 0);
        evdev_detach_client(evdev, client);
        kfree(client);
 
index 65d7077a75a19202288d4bc4484c19ca9b93c5c2..a85b1485e77499cd6afb15f46590b82951e1aa9e 100644 (file)
@@ -244,7 +244,6 @@ static int joydev_release(struct inode *inode, struct file *file)
        struct joydev_client *client = file->private_data;
        struct joydev *joydev = client->joydev;
 
-       joydev_fasync(-1, file, 0);
        joydev_detach_client(joydev, client);
        kfree(client);
 
index 82ec6b1b646782276363f769bc73e96226237459..216a559f55ea5c706731afc7f7f4abc1219891ed 100644 (file)
@@ -71,7 +71,6 @@ static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
 static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait);
 
 static int hp_sdc_rtc_open(struct inode *inode, struct file *file);
-static int hp_sdc_rtc_release(struct inode *inode, struct file *file);
 static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on);
 
 static 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)
         return 0;
 }
 
-static int hp_sdc_rtc_release(struct inode *inode, struct file *file)
-{
-       /* Turn off interrupts? */
-
-        if (file->f_flags & FASYNC) {
-                hp_sdc_rtc_fasync (-1, file, 0);
-        }
-
-        return 0;
-}
-
 static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on)
 {
         return fasync_helper (fd, filp, on, &hp_sdc_rtc_async_queue);
@@ -680,7 +668,6 @@ static const struct file_operations hp_sdc_rtc_fops = {
         .poll =                hp_sdc_rtc_poll,
         .ioctl =       hp_sdc_rtc_ioctl,
         .open =                hp_sdc_rtc_open,
-        .release =     hp_sdc_rtc_release,
         .fasync =      hp_sdc_rtc_fasync,
 };
 
index 8137e50ded87de13d31d378557a68ba58d3cedb5..d8c056fe7e982c2ee1f1dc39298e0e4721a06921 100644 (file)
@@ -519,7 +519,6 @@ static int mousedev_release(struct inode *inode, struct file *file)
        struct mousedev_client *client = file->private_data;
        struct mousedev *mousedev = client->mousedev;
 
-       mousedev_fasync(-1, file, 0);
        mousedev_detach_client(mousedev, client);
        kfree(client);
 
index 470770c09260334fd79c664c2a484ed0384a9f93..06bbd0e74c6f96d37ff423c60f78eebe92f8fb83 100644 (file)
@@ -135,7 +135,6 @@ static int serio_raw_release(struct inode *inode, struct file *file)
 
        mutex_lock(&serio_raw_mutex);
 
-       serio_raw_fasync(-1, file, 0);
        serio_raw_cleanup(serio_raw);
 
        mutex_unlock(&serio_raw_mutex);
index f5233f3d9eff03399c13e3e0b7138ad620056797..b89f476cd0a98e922f93e90dc04a2bd383af022e 100644 (file)
@@ -559,12 +559,6 @@ mptctl_fasync(int fd, struct file *filep, int mode)
        return ret;
 }
 
-static int
-mptctl_release(struct inode *inode, struct file *filep)
-{
-       return fasync_helper(-1, filep, 0, &async_queue);
-}
-
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
  *  MPT ioctl handler
@@ -2706,7 +2700,6 @@ mptctl_hp_targetinfo(unsigned long arg)
 static const struct file_operations mptctl_fops = {
        .owner =        THIS_MODULE,
        .llseek =       no_llseek,
-       .release =      mptctl_release,
        .fasync =       mptctl_fasync,
        .unlocked_ioctl = mptctl_ioctl,
 #ifdef CONFIG_COMPAT
index a3fabdbe6ca6eb01efc616aee7df91cc4ae312c1..f3384c32b9a1e3910e39f9331dd14a4ed382eb7f 100644 (file)
@@ -1097,28 +1097,17 @@ static int cfg_fasync(int fd, struct file *fp, int on)
 static int cfg_release(struct inode *inode, struct file *file)
 {
        ulong id = (ulong) file->private_data;
-       struct i2o_cfg_info *p1, *p2;
+       struct i2o_cfg_info *p, **q;
        unsigned long flags;
 
        lock_kernel();
-       p1 = p2 = NULL;
-
        spin_lock_irqsave(&i2o_config_lock, flags);
-       for (p1 = open_files; p1;) {
-               if (p1->q_id == id) {
-
-                       if (p1->fasync)
-                               cfg_fasync(-1, file, 0);
-                       if (p2)
-                               p2->next = p1->next;
-                       else
-                               open_files = p1->next;
-
-                       kfree(p1);
+       for (q = &open_files; (p = *q) != NULL; q = &p->next) {
+               if (p->q_id == id) {
+                       *q = p->next;
+                       kfree(p);
                        break;
                }
-               p2 = p1;
-               p1 = p1->next;
        }
        spin_unlock_irqrestore(&i2o_config_lock, flags);
        unlock_kernel();
index f483c4221f7602cb80022699e98008c5e2d33d79..06f07e19dc70748173c373a6dacc07cc25a72935 100644 (file)
@@ -1920,7 +1920,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);
        atomic_dec(&sonypi_compat.open_count);
        return 0;
 }
index 6daea0c91862ecddc2110712c8e62381e1e9639c..33b6d1b122fb59fdadfdd2f156a0596f37efcc25 100644 (file)
@@ -1070,8 +1070,6 @@ static int tun_chr_close(struct inode *inode, struct file *file)
 
        DBG(KERN_INFO "%s: tun_chr_close\n", tun->dev->name);
 
-       tun_chr_fasync(-1, file, 0);
-
        rtnl_lock();
 
        /* Detach from net device */
index 079e9ed907e06caa6d5a453c56c31e413f0cf6c5..ecdea44ae4e5465ddeb37e07361d74f020aa65da 100644 (file)
@@ -446,9 +446,6 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
        if (rtc->ops->release)
                rtc->ops->release(rtc->dev.parent);
 
-       if (file->f_flags & FASYNC)
-               rtc_dev_fasync(-1, file, 0);
-
        clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
        return 0;
 }
index afe1de99876319ba40d7c28a884458a3bff1b91e..a454f94623d73348491ccc603070cc55e0866edd 100644 (file)
@@ -2987,17 +2987,6 @@ static int megasas_mgmt_open(struct inode *inode, struct file *filep)
        return 0;
 }
 
-/**
- * megasas_mgmt_release - char node "release" entry point
- */
-static int megasas_mgmt_release(struct inode *inode, struct file *filep)
-{
-       filep->private_data = NULL;
-       fasync_helper(-1, filep, 0, &megasas_async_queue);
-
-       return 0;
-}
-
 /**
  * megasas_mgmt_fasync -       Async notifier registration from applications
  *
@@ -3345,7 +3334,6 @@ megasas_mgmt_compat_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations megasas_mgmt_fops = {
        .owner = THIS_MODULE,
        .open = megasas_mgmt_open,
-       .release = megasas_mgmt_release,
        .fasync = megasas_mgmt_fasync,
        .unlocked_ioctl = megasas_mgmt_ioctl,
 #ifdef CONFIG_COMPAT
index 9adf35bd8b5667f6c535070729194d1c04bfe291..5103855242ae7bcaa4b29e488432ff2688b5ae46 100644 (file)
@@ -327,7 +327,6 @@ sg_release(struct inode *inode, struct file *filp)
        if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
                return -ENXIO;
        SCSI_LOG_TIMEOUT(3, printk("sg_release: %s\n", sdp->disk->disk_name));
-       sg_fasync(-1, filp, 0); /* remove filp from async notification list */
        if (0 == sg_remove_sfp(sdp, sfp)) {     /* Returns 1 when sdp gone */
                if (!sdp->detached) {
                        scsi_device_put(sdp->device);
index 0b33773bb4f68412d5d44f3b99fed07fb1ab2041..cf8b01bcac8d18d25e5c18e1afe55d9f8d82fa8b 100644 (file)
@@ -1633,9 +1633,6 @@ static int me4000_release(struct inode *inode_p, struct file *file_p)
 
                free_irq(ext_int_context->irq, ext_int_context);
 
-               /* Delete the fasync structure and free memory */
-               me4000_ext_int_fasync(0, file_p, 0);
-
                /* Mark as unused */
                ext_int_context->in_use = 0;
        } else {
index 41b6530b8f251d0a2d5193eb58297ee3a99f30ac..a913efc69669a221d336006a35d5155000a6081a 100644 (file)
@@ -2328,7 +2328,6 @@ static int ixj_release(struct inode *inode, struct file *file_p)
        j->rec_codec = j->play_codec = 0;
        j->rec_frame_size = j->play_frame_size = 0;
        j->flags.cidsent = j->flags.cidring = 0;
-       ixj_fasync(-1, file_p, 0);      /* remove from list of async notification */
 
        if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) {
                ixj_set_port(j, PORT_PSTN);
index f9b4647255aa041fa816612bdcd618bc4ecbabcc..2d2440cd57a947d195d1f099d1a0ac64bdd56031 100644 (file)
@@ -367,9 +367,6 @@ static int uio_release(struct inode *inode, struct file *filep)
                ret = idev->info->release(idev->info, inode);
 
        module_put(idev->owner);
-
-       if (filep->f_flags & FASYNC)
-               ret = uio_fasync(-1, filep, 0);
        kfree(listener);
        return ret;
 }
index f4585d3e90d7a54fd4836648e2cb50eed7d7a947..eeb26c0f88e5846d4c0849e70ddf01eea90fa65d 100644 (file)
@@ -1251,7 +1251,6 @@ dev_release (struct inode *inode, struct file *fd)
         * alternatively, all host requests will time out.
         */
 
-       fasync_helper (-1, fd, 0, &dev->fasync);
        kfree (dev->buf);
        dev->buf = NULL;
        put_dev (dev);
index efc06faede6c3d6c27c324da2042b7d324e53f8e..5ad0eca6eea27b1ee33fcd8415c05edfeac97d82 100644 (file)
@@ -269,6 +269,10 @@ void __fput(struct file *file)
        eventpoll_release(file);
        locks_remove_flock(file);
 
+       if (unlikely(file->f_flags & FASYNC)) {
+               if (file->f_op && file->f_op->fasync)
+                       file->f_op->fasync(-1, file, 0);
+       }
        if (file->f_op && file->f_op->release)
                file->f_op->release(inode, file);
        security_file_free(file);
index 87250b6a8682468c39ff0e4cb1f35caa09f386f6..b72361479be25789e8caa4e6be5febe1f276419e 100644 (file)
@@ -1056,7 +1056,6 @@ static int fuse_dev_release(struct inode *inode, struct file *file)
                end_requests(fc, &fc->pending);
                end_requests(fc, &fc->processing);
                spin_unlock(&fc->lock);
-               fasync_helper(-1, file, 0, &fc->fasync);
                fuse_conn_put(fc);
        }
 
index d85c7d931cdfd4cb4cfa5bc839b08b4de22f9bb1..d367e9b9286276db8c686c96485d29fefdbe876e 100644 (file)
@@ -537,9 +537,6 @@ static int inotify_release(struct inode *ignored, struct file *file)
                inotify_dev_event_dequeue(dev);
        mutex_unlock(&dev->ev_mutex);
 
-       if (file->f_flags & FASYNC)
-               inotify_fasync(-1, file, 0);
-
        /* free this device: the put matching the get in inotify_init() */
        put_inotify_dev(dev);
 
index fcba6542b8d0132b72be8a93959a60b57c556e38..7aea8b89baac9c8b550d17f8c14f592d63e08981 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -717,14 +717,12 @@ pipe_rdwr_fasync(int fd, struct file *filp, int on)
 static int
 pipe_read_release(struct inode *inode, struct file *filp)
 {
-       pipe_read_fasync(-1, filp, 0);
        return pipe_release(inode, 1, 0);
 }
 
 static int
 pipe_write_release(struct inode *inode, struct file *filp)
 {
-       pipe_write_fasync(-1, filp, 0);
        return pipe_release(inode, 0, 1);
 }
 
@@ -733,7 +731,6 @@ pipe_rdwr_release(struct inode *inode, struct file *filp)
 {
        int decr, decw;
 
-       pipe_rdwr_fasync(-1, filp, 0);
        decr = (filp->f_mode & FMODE_READ) != 0;
        decw = (filp->f_mode & FMODE_WRITE) != 0;
        return pipe_release(inode, decr, decw);
index 2b7a4b5c9b7254c2ca0534cd174de5bb004a7659..57550c3bcabec28ab7ee82030e6d1d4cb36192a0 100644 (file)
@@ -990,7 +990,6 @@ static int sock_close(struct inode *inode, struct file *filp)
                printk(KERN_DEBUG "sock_close: NULL inode\n");
                return 0;
        }
-       sock_fasync(-1, filp, 0);
        sock_release(SOCKET_I(inode));
        return 0;
 }
index b0bf42691047307adc597b3c11a2a1c583f56e14..636b3b52ef8bdd56cc2f7eaccf6a779ca8c9c841 100644 (file)
@@ -113,7 +113,6 @@ static int snd_ctl_release(struct inode *inode, struct file *file)
        unsigned int idx;
 
        ctl = file->private_data;
-       fasync_helper(-1, file, 0, &ctl->fasync);
        file->private_data = NULL;
        card = ctl->card;
        write_lock_irqsave(&card->ctl_files_rwlock, flags);
index ef2352c2e45116a824f4e8275e590a2c7394594b..b47ff8b44be8dda901e0c88bd2c3089c2d4704ad 100644 (file)
@@ -264,8 +264,11 @@ static int snd_disconnect_release(struct inode *inode, struct file *file)
        }
        spin_unlock(&shutdown_lock);
 
-       if (likely(df))
+       if (likely(df)) {
+               if ((file->f_flags & FASYNC) && df->disconnected_f_op->fasync)
+                       df->disconnected_f_op->fasync(-1, file, 0);
                return df->disconnected_f_op->release(inode, file);
+       }
 
        panic("%s(%p, %p) failed!", __func__, inode, file);
 }
index aef18682c03569b792ad9d44b13432288406dbe2..a789efc9df3971e46b4f2535d57a4329d5b27dc2 100644 (file)
@@ -2169,7 +2169,6 @@ static int snd_pcm_release(struct inode *inode, struct file *file)
        if (snd_BUG_ON(!substream))
                return -ENXIO;
        pcm = substream->pcm;
-       fasync_helper(-1, file, 0, &substream->runtime->fasync);
        mutex_lock(&pcm->open_mutex);
        snd_pcm_release_substream(substream);
        kfree(pcm_file);
index e582face89d2c463aeb64ed0ee2001d738b54b5c..c584408c9f17d32dcace6b8684bfe02647a0f228 100644 (file)
@@ -1263,7 +1263,6 @@ static int snd_timer_user_release(struct inode *inode, struct file *file)
        if (file->private_data) {
                tu = file->private_data;
                file->private_data = NULL;
-               fasync_helper(-1, file, 0, &tu->fasync);
                if (tu->timeri)
                        snd_timer_close(tu->timeri);
                kfree(tu->queue);