atom feed3 messages in org.kernel.vger.kernel-janitors[patch 2/2] ptp: fix some locking bug...
FromSent OnAttachments
Dan CarpenterMay 29, 2011 12:54 pm 
Richard CochranMay 29, 2011 11:16 pm 
Richard CochranJun 1, 2011 3:17 am 
Subject:[patch 2/2] ptp: fix some locking bugs in ptp_read()
From:Dan Carpenter (erro@gmail.com)
Date:May 29, 2011 12:54:07 pm
List:org.kernel.vger.kernel-janitors

There was an unlock missing on an error path, and a double unlock on another error path.

Signed-off-by: Dan Carpenter <erro@gmail.com>

diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index 93fa22d..e7f301da2 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, 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; }