Skip to content

Commit

Permalink
ptp: Fix some locking bugs in ptp_read()
Browse files Browse the repository at this point in the history
In ptp_read there is an unlock missing on an error path, and a double
unlock on another error path.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Richard Cochran <richard.cochran@omicron.at>
Signed-off-by: John Stultz <john.stultz@linaro.org>
  • Loading branch information
error27 authored and johnstultz-work committed Jun 2, 2011
1 parent e23ef22 commit fb5a18c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/ptp/ptp_chardev.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ ssize_t ptp_read(struct posix_clock *pc,
return -ERESTARTSYS;
}

if (ptp->defunct)
if (ptp->defunct) {
mutex_unlock(&ptp->tsevq_mux);
return -ENODEV;
}

spin_lock_irqsave(&queue->lock, flags);

Expand All @@ -151,10 +153,8 @@ ssize_t ptp_read(struct posix_clock *pc,

mutex_unlock(&ptp->tsevq_mux);

if (copy_to_user(buf, event, cnt)) {
mutex_unlock(&ptp->tsevq_mux);
if (copy_to_user(buf, event, cnt))
return -EFAULT;
}

return cnt;
}

0 comments on commit fb5a18c

Please sign in to comment.