public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pps: locking scheme fix up for PPS_GETPARAMS.
@ 2009-10-31 16:03 Rodolfo Giometti
  2009-11-03  1:54 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Rodolfo Giometti @ 2009-10-31 16:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, Rodolfo Giometti

Signed-off-by: Rodolfo Giometti <giometti@linux.it>
Tested-by: Reg Clemens <clemens@dwf.com>
---
 drivers/pps/pps.c |   11 ++++++++---
 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;
 
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH] pps: locking scheme fix up for PPS_GETPARAMS.
@ 2009-11-06 10:49 Rodolfo Giometti
  0 siblings, 0 replies; 3+ messages in thread
From: Rodolfo Giometti @ 2009-11-06 10:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, Rodolfo Giometti

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>
---
 drivers/pps/pps.c |   11 ++++++++---
 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;
 
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-06 10:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-31 16:03 [PATCH] pps: locking scheme fix up for PPS_GETPARAMS Rodolfo Giometti
2009-11-03  1:54 ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2009-11-06 10:49 Rodolfo Giometti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox