From e0873c5a48536ee08da338b08baf0ee237c421f0 Mon Sep 17 00:00:00 2001 From: yangsen5 Date: Tue, 12 Sep 2023 09:57:59 +0800 Subject: [PATCH] drivers/video: Fix crash caused by priv->capture_cb = null When the upper layer calls goldfish_camera_data_uninit, priv->capture_cb=NULL, but when there is data transmission in goldfish_camera_thread, priv->capture_cb will be called, which will cause a crash. Signed-off-by: yangsen5 --- drivers/video/goldfish_camera.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/video/goldfish_camera.c b/drivers/video/goldfish_camera.c index 3fe0dfb4c6..b51c5c778c 100644 --- a/drivers/video/goldfish_camera.c +++ b/drivers/video/goldfish_camera.c @@ -464,6 +464,11 @@ reload: DEBUGASSERT(ret == priv->buf_size); + if (priv->capture_cb == NULL) + { + return 0; + } + clock_systime_timespec(&ts); TIMESPEC_TO_TIMEVAL(&tv, &ts); priv->capture_cb(0, priv->buf_size, &tv, priv->capture_arg);