Skip to content

Commit 3ae962f

Browse files
ngphibangjhedberg
authored andcommitted
samples: video: capture: Add check for buffer size and count
Verify the buffer size and the number of buffers before allocation. Signed-off-by: Phi Bang Nguyen <[email protected]>
1 parent c95ec70 commit 3ae962f

File tree

1 file changed

+6
-0
lines changed
  • samples/drivers/video/capture/src

1 file changed

+6
-0
lines changed

samples/drivers/video/capture/src/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ int main(void)
284284
}
285285

286286
/* Alloc video buffers and enqueue for capture */
287+
if (caps.min_vbuf_count > CONFIG_VIDEO_BUFFER_POOL_NUM_MAX ||
288+
bsize > CONFIG_VIDEO_BUFFER_POOL_SZ_MAX) {
289+
LOG_ERR("Not enough buffers or memory to start streaming");
290+
return 0;
291+
}
292+
287293
for (i = 0; i < CONFIG_VIDEO_BUFFER_POOL_NUM_MAX; i++) {
288294
/*
289295
* For some hardwares, such as the PxP used on i.MX RT1170 to do image rotation,

0 commit comments

Comments
 (0)