Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -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;