From a3db142fbfeb8abc7b9181133f727d8171789521 Mon Sep 17 00:00:00 2001 From: lile7 Date: Tue, 11 Jul 2023 21:21:34 +0800 Subject: [PATCH] drivers/video: use kmm_free(buff) to free memory instead of realloc(buff, 0) which is abandoned ref: https://github.com/apache/nuttx/pull/9151/commits/89d61f4eb4fd60ac88cd6a05b1957babcd4f9150 Signed-off-by: lile7 --- drivers/video/video_framebuff.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/video/video_framebuff.c b/drivers/video/video_framebuff.c index fc66745e9f..e03d6a929f 100644 --- a/drivers/video/video_framebuff.c +++ b/drivers/video/video_framebuff.c @@ -103,19 +103,27 @@ int video_framebuff_realloc_container(video_framebuff_t *fbuf, int sz) return OK; } - vbuf = kmm_realloc(fbuf->vbuf_alloced, sizeof(vbuf_container_t) * sz); - if (vbuf != NULL) + if (sz > 0) { - memset(vbuf, 0, sizeof(vbuf_container_t) * sz); + vbuf = kmm_realloc(fbuf->vbuf_alloced, sizeof(vbuf_container_t) * sz); + if (vbuf != NULL) + { + memset(vbuf, 0, sizeof(vbuf_container_t) * sz); + fbuf->vbuf_alloced = vbuf; + fbuf->container_size = sz; + } + else + { + return -ENOMEM; + } } - else if (sz != 0) + else { - return -ENOMEM; + kmm_free(fbuf->vbuf_alloced); + fbuf->vbuf_alloced = NULL; + fbuf->container_size = 0; } - fbuf->vbuf_alloced = vbuf; - fbuf->container_size = sz; - init_buf_chain(fbuf); return OK; }