]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 6 Nov 2008 23:55:34 +0000 (15:55 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 6 Nov 2008 23:55:34 +0000 (15:55 -0800)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
  ieee1394: dv1394: fix possible deadlock in multithreaded clients
  ieee1394: raw1394: fix possible deadlock in multithreaded clients
  ieee1394: struct device - replace bus_id with dev_name(), dev_set_name()
  firewire: struct device - replace bus_id with dev_name(), dev_set_name()

1  2 
drivers/ieee1394/dv1394.c
drivers/ieee1394/raw1394.c

index 965cfdb84ebc757c0c170e437be99bf637b88dbd,53329972c7dba580df1b8bd830c8cf8a85545b47..c19f23267157621b2fa613c9ea23a3bf82af5393
@@@ -1270,8 -1270,14 +1270,14 @@@ static int dv1394_mmap(struct file *fil
        struct video_card *video = file_to_video_card(file);
        int retval = -EINVAL;
  
-       /* serialize mmap */
-       mutex_lock(&video->mtx);
+       /*
+        * We cannot use the blocking variant mutex_lock here because .mmap
+        * is called with mmap_sem held, while .ioctl, .read, .write acquire
+        * video->mtx and subsequently call copy_to/from_user which will
+        * grab mmap_sem in case of a page fault.
+        */
+       if (!mutex_trylock(&video->mtx))
+               return -EAGAIN;
  
        if ( ! video_card_initialized(video) ) {
                retval = do_dv1394_init_default(video);
@@@ -1828,6 -1834,9 +1834,6 @@@ static int dv1394_release(struct inode 
        /* 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);
  
@@@ -2293,10 -2302,10 +2299,10 @@@ static void dv1394_add_host(struct hpsb
  
        ohci = (struct ti_ohci *)host->hostdata;
  
 -      device_create_drvdata(hpsb_protocol_class, NULL,
 -                            MKDEV(IEEE1394_MAJOR,
 -                                  IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), NULL,
 -                            "dv1394-%d", id);
 +      device_create(hpsb_protocol_class, NULL,
 +                    MKDEV(IEEE1394_MAJOR,
 +                          IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
 +                    NULL, "dv1394-%d", id);
  
        dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
        dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
index 9f19ac492106a8107a0d9fc2f2af66d92908dfe0,4bdfff0a9191976ee43207431f2582f7f2d66b2d..bf7e761c12b1c50ba711ade60eef3e003b767a8e
@@@ -2268,7 -2268,8 +2268,8 @@@ static ssize_t raw1394_write(struct fil
                return -EFAULT;
        }
  
-       mutex_lock(&fi->state_mutex);
+       if (!mutex_trylock(&fi->state_mutex))
+               return -EAGAIN;
  
        switch (fi->state) {
        case opened:
@@@ -2548,7 -2549,8 +2549,8 @@@ static int raw1394_mmap(struct file *fi
        struct file_info *fi = file->private_data;
        int ret;
  
-       mutex_lock(&fi->state_mutex);
+       if (!mutex_trylock(&fi->state_mutex))
+               return -EAGAIN;
  
        if (fi->iso_state == RAW1394_ISO_INACTIVE)
                ret = -EINVAL;
@@@ -2669,7 -2671,8 +2671,8 @@@ static long raw1394_ioctl(struct file *
                break;
        }
  
-       mutex_lock(&fi->state_mutex);
+       if (!mutex_trylock(&fi->state_mutex))
+               return -EAGAIN;
  
        switch (fi->iso_state) {
        case RAW1394_ISO_INACTIVE:
@@@ -3034,10 -3037,10 +3037,10 @@@ static int __init init_raw1394(void
        hpsb_register_highlevel(&raw1394_highlevel);
  
        if (IS_ERR
 -          (device_create_drvdata(
 -            hpsb_protocol_class, NULL,
 -            MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
 -            NULL, RAW1394_DEVICE_NAME))) {
 +          (device_create(hpsb_protocol_class, NULL,
 +                         MKDEV(IEEE1394_MAJOR,
 +                               IEEE1394_MINOR_BLOCK_RAW1394 * 16),
 +                         NULL, RAW1394_DEVICE_NAME))) {
                ret = -EFAULT;
                goto out_unreg;
        }