mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -04:00
universal7885: fm-aidl: Fix deadlock on get mutex locked
- We started the function ensuring mutex is locked, and in the middle trying to lock again for return. This will cause deadlock or returning false forever. Therefore, put an if condition before locking at start of the function
This commit is contained in:
parent
4a7ed2114a
commit
8beec828f7
2 changed files with 12 additions and 4 deletions
|
|
@ -37,7 +37,9 @@ namespace aidl::vendor::eureka::hardware::fmradio {
|
|||
}
|
||||
|
||||
::ndk::ScopedAStatus FMDevControl::getValue(GetType type, int *_aidl_return) {
|
||||
RETURN_IF_FAILED_LOCK;
|
||||
if (type != GetType::GET_TYPE_FM_MUTEX_LOCKED) {
|
||||
RETURN_IF_FAILED_LOCK;
|
||||
}
|
||||
assert(fd > 0);
|
||||
switch (type) {
|
||||
case GetType::GET_TYPE_FM_FREQ:
|
||||
|
|
@ -85,7 +87,9 @@ namespace aidl::vendor::eureka::hardware::fmradio {
|
|||
default:
|
||||
break;
|
||||
};
|
||||
lock.unlock();
|
||||
if (type != GetType::GET_TYPE_FM_MUTEX_LOCKED) {
|
||||
lock.unlock();
|
||||
}
|
||||
return ::ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ constexpr const char *FM_FREQ_SEEK = FM_SYSFS_BASE "/radio_freq_seek";
|
|||
::ndk::ScopedAStatus FMSupport::open(void) { NOT_SUPPORTED; }
|
||||
|
||||
::ndk::ScopedAStatus FMSupport::getValue(GetType type, int *_aidl_return) {
|
||||
RETURN_IF_FAILED_LOCK;
|
||||
if (type != GetType::GET_TYPE_FM_MUTEX_LOCKED) {
|
||||
RETURN_IF_FAILED_LOCK;
|
||||
}
|
||||
switch (type) {
|
||||
case GetType::GET_TYPE_FM_FREQ:
|
||||
*_aidl_return = FileIO::readline(FM_FREQ_CTL);
|
||||
|
|
@ -76,7 +78,9 @@ constexpr const char *FM_FREQ_SEEK = FM_SYSFS_BASE "/radio_freq_seek";
|
|||
default:
|
||||
break;
|
||||
};
|
||||
lock.unlock();
|
||||
if (type != GetType::GET_TYPE_FM_MUTEX_LOCKED) {
|
||||
lock.unlock();
|
||||
}
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
::ndk::ScopedAStatus FMSupport::setValue(SetType type, int value) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue