[rtems commit] leon, grcan: protect statistics on copy to user
Daniel Hellstrom
danielh at rtems.org
Sun May 14 10:34:28 UTC 2017
Module: rtems
Branch: master
Commit: c297060b111701b2d16365485038e6cf80d279f2
Changeset: http://git.rtems.org/rtems/commit/?id=c297060b111701b2d16365485038e6cf80d279f2
Author: Martin Aberg <maberg at gaisler.com>
Date: Mon Mar 13 12:44:58 2017 +0100
leon, grcan: protect statistics on copy to user
Locking the stats structure when copying to user buffer ensures a consistent
view to the user.
---
c/src/lib/libbsp/sparc/shared/can/grcan.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/c/src/lib/libbsp/sparc/shared/can/grcan.c b/c/src/lib/libbsp/sparc/shared/can/grcan.c
index 409e68b..003cecf 100644
--- a/c/src/lib/libbsp/sparc/shared/can/grcan.c
+++ b/c/src/lib/libbsp/sparc/shared/can/grcan.c
@@ -1612,13 +1612,16 @@ int grcan_set_rxcomplete(void *d, int complete)
int grcan_get_stats(void *d, struct grcan_stats *stats)
{
struct grcan_priv *pDev = d;
+ SPIN_IRQFLAGS(oldLevel);
FUNCDBG();
if ( !stats )
return -1;
+ SPIN_LOCK_IRQ(&pDev->devlock, oldLevel);
*stats = pDev->stats;
+ SPIN_UNLOCK_IRQ(&pDev->devlock, oldLevel);
return 0;
}
More information about the vc
mailing list