Commit f22e52b8 authored by Stefan Richter's avatar Stefan Richter

ieee1394: raw1394: make write() thread-safe

Application programs should use a libraw1394 handle only in a single
thread.  The raw1394 driver was apparently relying on this, because it
did nothing to protect its fi->state variable from corruption due to
concurrent accesses.

We now serialize the fi->state accesses.  This affects the write() path.
We re-use the state_mutex which was introduced to protect fi->iso_state
accesses in the ioctl() path.  These paths and accesses are independent
of each other, hence separate mutexes could be used.  But I don't see
much benefit in that.
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent ddfb908d
...@@ -2268,6 +2268,8 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer, ...@@ -2268,6 +2268,8 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer,
return -EFAULT; return -EFAULT;
} }
mutex_lock(&fi->state_mutex);
switch (fi->state) { switch (fi->state) {
case opened: case opened:
retval = state_opened(fi, req); retval = state_opened(fi, req);
...@@ -2282,6 +2284,8 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer, ...@@ -2282,6 +2284,8 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer,
break; break;
} }
mutex_unlock(&fi->state_mutex);
if (retval < 0) { if (retval < 0) {
free_pending_request(req); free_pending_request(req);
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment