Skip to content

Commit 5d10955

Browse files
Alain Volmatkartben
authored andcommitted
video: common: add checks of frame interval values
Add checks regarding specific values (numerator / denominator) not being 0 for frame intervals. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
1 parent 5623772 commit 5d10955

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

include/zephyr/drivers/video.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ static inline int video_set_frmival(const struct device *dev, struct video_frmiv
421421
__ASSERT_NO_MSG(dev != NULL);
422422
__ASSERT_NO_MSG(frmival != NULL);
423423

424+
if (frmival->numerator == 0 || frmival->denominator == 0) {
425+
return -EINVAL;
426+
}
427+
424428
api = (const struct video_driver_api *)dev->api;
425429
if (api->set_frmival == NULL) {
426430
return -ENOSYS;
@@ -803,6 +807,7 @@ int video_format_caps_index(const struct video_format_cap *fmts, const struct vi
803807
static inline uint64_t video_frmival_nsec(const struct video_frmival *frmival)
804808
{
805809
__ASSERT_NO_MSG(frmival != NULL);
810+
__ASSERT_NO_MSG(frmival->denominator != 0);
806811

807812
return (uint64_t)NSEC_PER_SEC * frmival->numerator / frmival->denominator;
808813
}

0 commit comments

Comments
 (0)