Skip to content

Commit

Permalink
pps: locking scheme fix up for PPS_GETPARAMS
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rodolfo Giometti authored and Linus Torvalds committed Nov 12, 2009
1 parent 69fd8d2 commit cbf83cc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/pps/pps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit cbf83cc

Please sign in to comment.