camerad: zero memory before returning from MemoryManager::alloc (#30781)

* zero memory

* remove redundant memset

---------

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: b9080d23627849aafc4969d39df50cc615ffecdf
This commit is contained in:
Dean Lee
2023-12-19 05:54:11 +08:00
committed by GitHub
parent 6ae3e95542
commit cbbbaf22b7
2 changed files with 3 additions and 1 deletions

View File

@@ -135,7 +135,6 @@ int CameraState::sensors_init() {
buf_desc[1].size = buf_desc[1].length = 196;
buf_desc[1].type = CAM_CMD_BUF_I2C;
auto power_settings = mm.alloc<struct cam_cmd_power>(buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle);
memset(power_settings.get(), 0, buf_desc[1].size);
// power on
struct cam_cmd_power *power = power_settings.get();

View File

@@ -1,5 +1,7 @@
#include "system/camerad/cameras/camera_util.h"
#include <string.h>
#include <cassert>
#include <sys/ioctl.h>
@@ -111,6 +113,7 @@ void *MemoryManager::alloc_buf(int size, uint32_t *handle) {
size_lookup[ptr] = size;
}
lock.unlock();
memset(ptr, 0, size);
return ptr;
}