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
1 changed files with 4 additions and 4 deletions
|
@ -130,8 +130,10 @@ ssize_t ptp_read(struct posix_clock *pc,
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptp->defunct)
|
if (ptp->defunct) {
|
||||||
|
mutex_unlock(&ptp->tsevq_mux);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&queue->lock, flags);
|
spin_lock_irqsave(&queue->lock, flags);
|
||||||
|
|
||||||
|
@ -151,10 +153,8 @@ ssize_t ptp_read(struct posix_clock *pc,
|
||||||
|
|
||||||
mutex_unlock(&ptp->tsevq_mux);
|
mutex_unlock(&ptp->tsevq_mux);
|
||||||
|
|
||||||
if (copy_to_user(buf, event, cnt)) {
|
if (copy_to_user(buf, event, cnt))
|
||||||
mutex_unlock(&ptp->tsevq_mux);
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
|
||||||
|
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue