Commit cbf83cc5 authored by Rodolfo Giometti's avatar Rodolfo Giometti Committed by Linus Torvalds

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: default avatarRodolfo Giometti <giometti@linux.it>
Tested-by: default avatarReg Clemens <clemens@dwf.com>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 69fd8d24
......@@ -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;
......
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