aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ptp
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2011-05-29 15:54:07 -0400
committerJohn Stultz <john.stultz@linaro.org>2011-06-01 22:29:10 -0400
commitfb5a18cf7c771a12c3f42a5eb4b476eed68b77cb (patch)
tree99f023f49d8b88918f2ac5c9ce33b956e948b678 /drivers/ptp
parente23ef227d10878ff3f323a1dfed10205a1825b71 (diff)
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>
Diffstat (limited to 'drivers/ptp')
-rw-r--r--drivers/ptp/ptp_chardev.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index 93fa22de5977..e7f301da2902 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -130,8 +130,10 @@ ssize_t ptp_read(struct posix_clock *pc,
130 return -ERESTARTSYS; 130 return -ERESTARTSYS;
131 } 131 }
132 132
133 if (ptp->defunct) 133 if (ptp->defunct) {
134 mutex_unlock(&ptp->tsevq_mux);
134 return -ENODEV; 135 return -ENODEV;
136 }
135 137
136 spin_lock_irqsave(&queue->lock, flags); 138 spin_lock_irqsave(&queue->lock, flags);
137 139
@@ -151,10 +153,8 @@ ssize_t ptp_read(struct posix_clock *pc,
151 153
152 mutex_unlock(&ptp->tsevq_mux); 154 mutex_unlock(&ptp->tsevq_mux);
153 155
154 if (copy_to_user(buf, event, cnt)) { 156 if (copy_to_user(buf, event, cnt))
155 mutex_unlock(&ptp->tsevq_mux);
156 return -EFAULT; 157 return -EFAULT;
157 }
158 158
159 return cnt; 159 return cnt;
160} 160}