lkml.org 
[lkml]   [2021]   [Dec]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] media: vidtv: Check for null return of vzalloc
Date
As the possible failure of the vzalloc(), e->encoder_buf might be NULL.
Therefore, it should be better to check it like the kzalloc() in order
to guarantee the success of the initialization.

Fixes: f90cf6079bf6 ("media: vidtv: add a bridge driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/media/test-drivers/vidtv/vidtv_s302m.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.c b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
index d79b65854627..d7907f1ae530 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_s302m.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
@@ -455,6 +455,11 @@ struct vidtv_encoder
e->name = kstrdup(args.name, GFP_KERNEL);

e->encoder_buf = vzalloc(VIDTV_S302M_BUF_SZ);
+ if (!e->encoder_buf) {
+ kfree(e);
+ return NULL;
+ }
+
e->encoder_buf_sz = VIDTV_S302M_BUF_SZ;
e->encoder_buf_offset = 0;

--
2.25.1
\
 
 \ /
  Last update: 2021-12-31 08:51    [W:1.462 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site