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:
Martin Aberg
2017-03-13 12:44:58 +01:00
committed by Daniel Hellstrom
parent 7b8a920a27
commit c297060b11

View File

@@ -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;
}