tle6240: fix crash in driver wake routine (#1435)

This commit is contained in:
dron0gus 2020-05-15 22:54:41 +03:00 committed by GitHub
parent 258d23bc31
commit 7500e44c8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 10 deletions

View File

@ -314,17 +314,18 @@ static int tle6240_wake_driver(struct tle6240_priv *chip)
{
(void)chip;
if (isIsrContext()) {
// this is for normal runtime
int wasLocked = lockAnyContext();
chSemSignalI(&tle6240_wake);
if (!wasLocked) {
unlockAnyContext();
}
} else {
// this is for start-up to not hang up
chSemSignal(&tle6240_wake);
/* Entering a reentrant critical zone.*/
syssts_t sts = chSysGetStatusAndLockX();
chSemSignalI(&tle6240_wake);
if (!port_is_isr_context()) {
/**
* chSemSignalI above requires rescheduling
* interrupt handlers have implicit rescheduling
*/
chSchRescheduleS();
}
/* Leaving the critical zone.*/
chSysRestoreStatusX(sts);
return 0;
}