mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-29 07:04:10 +08:00
ptp: Fix some locking bugs in ptp_read()
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>
This commit is contained in:
parent
e23ef227d1
commit
fb5a18cf7c
@ -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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user