提交 0b21437c 编写于 作者: Z zhushengle

fixed 5caa08be from https://gitee.com/zhushengle/drivers_liteos/pulls/48

fix: 修复内存分配后未校验返回值的问题

Close #I632OQ
Signed-off-by: Nzhushengle <zhushengle@huawei.com>
Change-Id: If7e1f0ff6a17dc2d33fd486b16664306458bf343
上级 05e11968
...@@ -359,23 +359,31 @@ static struct file_operations_vfs g_hieventFops = { ...@@ -359,23 +359,31 @@ static struct file_operations_vfs g_hieventFops = {
.poll = HieventPoll, /* poll */ .poll = HieventPoll, /* poll */
}; };
static void HieventDeviceInit(void) static int HieventDeviceInit(void)
{ {
g_hieventDev.buffer = LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, g_hieventDev.buffer = LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR,
HIEVENT_LOG_BUFFER); HIEVENT_LOG_BUFFER);
if (g_hieventDev.buffer == NULL) {
return -ENOMEM;
}
init_waitqueue_head(&g_hieventDev.wq); init_waitqueue_head(&g_hieventDev.wq);
LOS_MuxInit(&g_hieventDev.mtx, NULL); (void)LOS_MuxInit(&g_hieventDev.mtx, NULL);
g_hieventDev.writeOffset = 0; g_hieventDev.writeOffset = 0;
g_hieventDev.headOffset = 0; g_hieventDev.headOffset = 0;
g_hieventDev.size = 0; g_hieventDev.size = 0;
g_hieventDev.count = 0; g_hieventDev.count = 0;
return 0;
} }
int HieventInit(void) int HieventInit(void)
{ {
HieventDeviceInit(); int ret = HieventDeviceInit();
if (ret != 0) {
return ret;
}
register_driver("/dev/hwlog_exception", &g_hieventFops, register_driver("/dev/hwlog_exception", &g_hieventFops,
DRIVER_MODE, &g_hieventDev); DRIVER_MODE, &g_hieventDev);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册