Skip to content

Commit

Permalink
firewire: cdev: fix race in iso context creation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Clemens Ladisch authored and Stefan Richter committed Jun 20, 2010
1 parent 33e553f commit bdfe273
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/firewire/core-cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,10 +864,6 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
struct fw_cdev_create_iso_context *a = &arg->create_iso_context;
struct fw_iso_context *context;

/* We only support one context at this time. */
if (client->iso_context != NULL)
return -EBUSY;

if (a->channel > 63)
return -EINVAL;

Expand All @@ -892,10 +888,17 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
if (IS_ERR(context))
return PTR_ERR(context);

/* We only support one context at this time. */
spin_lock_irq(&client->lock);
if (client->iso_context != NULL) {
spin_unlock_irq(&client->lock);
fw_iso_context_destroy(context);
return -EBUSY;
}
client->iso_closure = a->closure;
client->iso_context = context;
spin_unlock_irq(&client->lock);

/* We only support one context at this time. */
a->handle = 0;

return 0;
Expand Down

0 comments on commit bdfe273

Please sign in to comment.