summaryrefslogtreecommitdiffstats
path: root/drivers/pps
diff options
context:
space:
mode:
authorRodolfo Giometti <giometti@linux.it>2009-11-11 14:26:52 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2009-11-12 07:26:00 -0800
commitcbf83cc5a29dba480cf1ba1c5e3417a0d4a31410 (patch)
treeeb7757638e0a8e5509066eebec053a7bffe0138a /drivers/pps
parent69fd8d24673a8f4f8be5db7f84b5dc9e4ff354c8 (diff)
downloadop-kernel-dev-cbf83cc5a29dba480cf1ba1c5e3417a0d4a31410.zip
op-kernel-dev-cbf83cc5a29dba480cf1ba1c5e3417a0d4a31410.tar.gz
pps: locking scheme fix up for PPS_GETPARAMS
Userland programs may read/write PPS parameters at same time and these operations may corrupt PPS data. Signed-off-by: Rodolfo Giometti <giometti@linux.it> Tested-by: Reg Clemens <clemens@dwf.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pps')
-rw-r--r--drivers/pps/pps.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index fea17e7..ca5183b 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -71,9 +71,14 @@ static long pps_cdev_ioctl(struct file *file,
case PPS_GETPARAMS:
pr_debug("PPS_GETPARAMS: source %d\n", pps->id);
- /* Return current parameters */
- err = copy_to_user(uarg, &pps->params,
- sizeof(struct pps_kparams));
+ spin_lock_irq(&pps->lock);
+
+ /* Get the current parameters */
+ params = pps->params;
+
+ spin_unlock_irq(&pps->lock);
+
+ err = copy_to_user(uarg, &params, sizeof(struct pps_kparams));
if (err)
return -EFAULT;
OpenPOWER on IntegriCloud