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>
This commit is contained in:
Rodolfo Giometti 2009-11-11 14:26:52 -08:00 committed by Linus Torvalds
parent 69fd8d2467
commit cbf83cc5a2

View file

@ -71,9 +71,14 @@ static long pps_cdev_ioctl(struct file *file,
case PPS_GETPARAMS: case PPS_GETPARAMS:
pr_debug("PPS_GETPARAMS: source %d\n", pps->id); pr_debug("PPS_GETPARAMS: source %d\n", pps->id);
/* Return current parameters */ spin_lock_irq(&pps->lock);
err = copy_to_user(uarg, &pps->params,
sizeof(struct pps_kparams)); /* Get the current parameters */
params = pps->params;
spin_unlock_irq(&pps->lock);
err = copy_to_user(uarg, &params, sizeof(struct pps_kparams));
if (err) if (err)
return -EFAULT; return -EFAULT;