mirror of
https://github.com/openharmony/drivers_framework.git
synced 2026-08-27 02:42:28 -04:00
fix: fix the bug that release the memory and lock resource of manager->eventMutex
Signed-off-by: sunxuejiao <sunxuejiao5@huawei.com>
This commit is contained in:
@@ -88,14 +88,16 @@ int32_t DeleteSensorDevice(const struct SensorBasicInfo *sensorBaseInfo)
|
||||
int32_t ReportSensorEvent(const struct SensorReportEvent *events)
|
||||
{
|
||||
int32_t ret;
|
||||
struct SensorDevMgrData *manager = NULL;
|
||||
struct HdfSBuf *msg = NULL;
|
||||
|
||||
CHECK_NULL_PTR_RETURN_VALUE(events, HDF_ERR_INVALID_PARAM);
|
||||
|
||||
struct SensorDevMgrData *manager = GetSensorDeviceManager();
|
||||
manager = GetSensorDeviceManager();
|
||||
CHECK_NULL_PTR_RETURN_VALUE(manager, HDF_ERR_INVALID_PARAM);
|
||||
|
||||
(void)OsalMutexLock(&manager->eventMutex);
|
||||
struct HdfSBuf *msg = HdfSBufObtain(HDF_SENSOR_EVENT_MAX_BUF);
|
||||
msg = HdfSBufObtain(HDF_SENSOR_EVENT_MAX_BUF);
|
||||
if (msg == NULL) {
|
||||
(void)OsalMutexUnlock(&manager->eventMutex);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
@@ -128,11 +130,14 @@ EXIT:
|
||||
|
||||
static int32_t GetAllSensorInfo(struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
(void)data;
|
||||
int32_t count = 0;
|
||||
struct SensorDevInfoNode *pos = NULL;
|
||||
struct SensorBasicInfo *sensorInfo = NULL;
|
||||
struct SensorDevMgrData *manager = GetSensorDeviceManager();
|
||||
int32_t count = 0;
|
||||
struct SensorDevMgrData *manager = NULL;
|
||||
|
||||
(void)data;
|
||||
|
||||
manager = GetSensorDeviceManager();
|
||||
|
||||
CHECK_NULL_PTR_RETURN_VALUE(reply, HDF_ERR_INVALID_PARAM);
|
||||
CHECK_NULL_PTR_RETURN_VALUE(manager, HDF_ERR_INVALID_PARAM);
|
||||
@@ -303,9 +308,11 @@ static int32_t DispatchSensor(struct HdfDeviceIoClient *client,
|
||||
|
||||
int32_t BindSensorDevManager(struct HdfDeviceObject *device)
|
||||
{
|
||||
struct SensorDevMgrData *manager = NULL;
|
||||
|
||||
CHECK_NULL_PTR_RETURN_VALUE(device, HDF_ERR_INVALID_PARAM);
|
||||
|
||||
struct SensorDevMgrData *manager = (struct SensorDevMgrData *)OsalMemCalloc(sizeof(*manager));
|
||||
manager = (struct SensorDevMgrData *)OsalMemCalloc(sizeof(*manager));
|
||||
if (manager == NULL) {
|
||||
HDF_LOGE("%s: malloc manager fail!", __func__);
|
||||
return HDF_ERR_MALLOC_FAIL;
|
||||
@@ -321,8 +328,10 @@ int32_t BindSensorDevManager(struct HdfDeviceObject *device)
|
||||
|
||||
int32_t InitSensorDevManager(struct HdfDeviceObject *device)
|
||||
{
|
||||
struct SensorDevMgrData *manager = NULL;
|
||||
|
||||
CHECK_NULL_PTR_RETURN_VALUE(device, HDF_ERR_INVALID_PARAM);
|
||||
struct SensorDevMgrData *manager = (struct SensorDevMgrData *)device->service;
|
||||
manager = (struct SensorDevMgrData *)device->service;
|
||||
CHECK_NULL_PTR_RETURN_VALUE(manager, HDF_ERR_INVALID_PARAM);
|
||||
|
||||
DListHeadInit(&manager->sensorDevInfoHead);
|
||||
@@ -347,11 +356,13 @@ int32_t InitSensorDevManager(struct HdfDeviceObject *device)
|
||||
|
||||
void ReleaseSensorDevManager(struct HdfDeviceObject *device)
|
||||
{
|
||||
CHECK_NULL_PTR_RETURN(device);
|
||||
|
||||
struct SensorDevInfoNode *pos = NULL;
|
||||
struct SensorDevInfoNode *tmp = NULL;
|
||||
struct SensorDevMgrData *manager = (struct SensorDevMgrData *)device->service;
|
||||
struct SensorDevMgrData *manager = NULL;
|
||||
|
||||
CHECK_NULL_PTR_RETURN(device);
|
||||
|
||||
manager = (struct SensorDevMgrData *)device->service;
|
||||
CHECK_NULL_PTR_RETURN(manager);
|
||||
|
||||
DLIST_FOR_EACH_ENTRY_SAFE(pos, tmp, &manager->sensorDevInfoHead, struct SensorDevInfoNode, node) {
|
||||
@@ -360,6 +371,7 @@ void ReleaseSensorDevManager(struct HdfDeviceObject *device)
|
||||
}
|
||||
|
||||
OsalMutexDestroy(&manager->mutex);
|
||||
OsalMutexDestroy(&manager->eventMutex);
|
||||
OsalMemFree(manager);
|
||||
g_sensorDeviceManager = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user