]> err.no Git - linux-2.6/blobdiff - drivers/firewire/fw-cdev.c
V4L/DVB (7858): video: build fix for drivers/media/video/mt9v022.c
[linux-2.6] / drivers / firewire / fw-cdev.c
index 44ccee26c368b59c030b1b07a4b92c157fac4069..4a541921a14a26e2a24c8c814b92f17035098de3 100644 (file)
@@ -269,21 +269,28 @@ static int ioctl_get_info(struct client *client, void *buffer)
 {
        struct fw_cdev_get_info *get_info = buffer;
        struct fw_cdev_event_bus_reset bus_reset;
+       unsigned long ret = 0;
 
        client->version = get_info->version;
        get_info->version = FW_CDEV_VERSION;
 
+       down_read(&fw_device_rwsem);
+
        if (get_info->rom != 0) {
                void __user *uptr = u64_to_uptr(get_info->rom);
                size_t want = get_info->rom_length;
                size_t have = client->device->config_rom_length * 4;
 
-               if (copy_to_user(uptr, client->device->config_rom,
-                                min(want, have)))
-                       return -EFAULT;
+               ret = copy_to_user(uptr, client->device->config_rom,
+                                  min(want, have));
        }
        get_info->rom_length = client->device->config_rom_length * 4;
 
+       up_read(&fw_device_rwsem);
+
+       if (ret != 0)
+               return -EFAULT;
+
        client->bus_reset_closure = get_info->bus_reset_closure;
        if (get_info->bus_reset != 0) {
                void __user *uptr = u64_to_uptr(get_info->bus_reset);
@@ -646,6 +653,10 @@ static int ioctl_create_iso_context(struct client *client, void *buffer)
        struct fw_cdev_create_iso_context *request = buffer;
        struct fw_iso_context *context;
 
+       /* We only support one context at this time. */
+       if (client->iso_context != NULL)
+               return -EBUSY;
+
        if (request->channel > 63)
                return -EINVAL;
 
@@ -792,8 +803,9 @@ static int ioctl_start_iso(struct client *client, void *buffer)
 {
        struct fw_cdev_start_iso *request = buffer;
 
-       if (request->handle != 0)
+       if (client->iso_context == NULL || request->handle != 0)
                return -EINVAL;
+
        if (client->iso_context->type == FW_ISO_CONTEXT_RECEIVE) {
                if (request->tags == 0 || request->tags > 15)
                        return -EINVAL;
@@ -810,7 +822,7 @@ static int ioctl_stop_iso(struct client *client, void *buffer)
 {
        struct fw_cdev_stop_iso *request = buffer;
 
-       if (request->handle != 0)
+       if (client->iso_context == NULL || request->handle != 0)
                return -EINVAL;
 
        return fw_iso_context_stop(client->iso_context);