Commit fb5a18cf authored by Dan Carpenter's avatar Dan Carpenter Committed by John Stultz

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: default avatarDan Carpenter <error27@gmail.com>
Acked-by: default avatarRichard Cochran <richard.cochran@omicron.at>
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
parent e23ef227
...@@ -130,8 +130,10 @@ ssize_t ptp_read(struct posix_clock *pc, ...@@ -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, ...@@ -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;
} }
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