forked from Imagelibrary/rtems
leon, grcan: protect statistics on copy to user
Locking the stats structure when copying to user buffer ensures a consistent view to the user.
This commit is contained in:
committed by
Daniel Hellstrom
parent
7b8a920a27
commit
c297060b11
@@ -1612,13 +1612,16 @@ int grcan_set_rxcomplete(void *d, int complete)
|
|||||||
int grcan_get_stats(void *d, struct grcan_stats *stats)
|
int grcan_get_stats(void *d, struct grcan_stats *stats)
|
||||||
{
|
{
|
||||||
struct grcan_priv *pDev = d;
|
struct grcan_priv *pDev = d;
|
||||||
|
SPIN_IRQFLAGS(oldLevel);
|
||||||
|
|
||||||
FUNCDBG();
|
FUNCDBG();
|
||||||
|
|
||||||
if ( !stats )
|
if ( !stats )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
SPIN_LOCK_IRQ(&pDev->devlock, oldLevel);
|
||||||
*stats = pDev->stats;
|
*stats = pDev->stats;
|
||||||
|
SPIN_UNLOCK_IRQ(&pDev->devlock, oldLevel);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user