Skip to content

Commit

Permalink
ieee1394: raw1394: Do not leak memory on failed trylock.
Browse files Browse the repository at this point in the history
Do not leak the allocated memory in case the mutex_trylock() failed
to acquire the lock.

Signed-off-by: Michael Buesch <mb@bu3sch.de>

This bug does not happen in practice:  All raw1394 clients use
libraw1394, and accesses to a libraw1394 handle need to be serialized
by the client.  This is documented in libraw1394's API reference.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
  • Loading branch information
Michael Buesch authored and Stefan Richter committed Sep 12, 2009
1 parent 74fca6a commit 64549e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/ieee1394/raw1394.c
Original file line number Diff line number Diff line change
Expand Up @@ -2272,8 +2272,10 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer,
return -EFAULT;
}

if (!mutex_trylock(&fi->state_mutex))
if (!mutex_trylock(&fi->state_mutex)) {
free_pending_request(req);
return -EAGAIN;
}

switch (fi->state) {
case opened:
Expand Down

0 comments on commit 64549e9

Please sign in to comment.