aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2010-06-14 05:46:25 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2010-06-20 17:11:56 -0400
commitbdfe273ee54b29498851fc8058516037d284270c (patch)
tree1e4a94774ae5469ee6e4bc9bd5bb1e43db67c511 /drivers
parent33e553fe2b4a983ef34a57ab1440d8d33397bb12 (diff)
firewire: cdev: fix race in iso context creation
Protect the client's iso context pointer against a race that can happen when more than one creation call is executed at the same time. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firewire/core-cdev.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 4e0478d70d4d..ce8cb6fcbbcd 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -864,10 +864,6 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
864 struct fw_cdev_create_iso_context *a = &arg->create_iso_context; 864 struct fw_cdev_create_iso_context *a = &arg->create_iso_context;
865 struct fw_iso_context *context; 865 struct fw_iso_context *context;
866 866
867 /* We only support one context at this time. */
868 if (client->iso_context != NULL)
869 return -EBUSY;
870
871 if (a->channel > 63) 867 if (a->channel > 63)
872 return -EINVAL; 868 return -EINVAL;
873 869
@@ -892,10 +888,17 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
892 if (IS_ERR(context)) 888 if (IS_ERR(context))
893 return PTR_ERR(context); 889 return PTR_ERR(context);
894 890
891 /* We only support one context at this time. */
892 spin_lock_irq(&client->lock);
893 if (client->iso_context != NULL) {
894 spin_unlock_irq(&client->lock);
895 fw_iso_context_destroy(context);
896 return -EBUSY;
897 }
895 client->iso_closure = a->closure; 898 client->iso_closure = a->closure;
896 client->iso_context = context; 899 client->iso_context = context;
900 spin_unlock_irq(&client->lock);
897 901
898 /* We only support one context at this time. */
899 a->handle = 0; 902 a->handle = 0;
900 903
901 return 0; 904 return 0;