[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220112013439.668397-1-jiasheng@iscas.ac.cn>
Date: Wed, 12 Jan 2022 09:34:39 +0800
From: Jiasheng Jiang <jiasheng@...as.ac.cn>
To: hverkuil@...all.nl, dwlsalmeida@...il.com, mchehab@...nel.org
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH v2] media: vidtv: Check for null return of vzalloc
As the possible failure of the vzalloc(), e->encoder_buf might be NULL.
Therefore, it should be better to check it in order
to guarantee the success of the initialization.
If fails, we need to free not only 'e' but also 'e->name'.
Fixes: f90cf6079bf6 ("media: vidtv: add a bridge driver")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
Changelog
v1 -> v2
* Change 1. Add 'kfree(e->name)' if fails.
---
drivers/media/test-drivers/vidtv/vidtv_s302m.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.c b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
index d79b65854627..ddaff46c440f 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_s302m.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
@@ -455,6 +455,12 @@ struct vidtv_encoder
e->name = kstrdup(args.name, GFP_KERNEL);
e->encoder_buf = vzalloc(VIDTV_S302M_BUF_SZ);
+ if (!e->encoder_buf) {
+ kfree(e->name);
+ kfree(e);
+ return NULL;
+ }
+
e->encoder_buf_sz = VIDTV_S302M_BUF_SZ;
e->encoder_buf_offset = 0;
--
2.25.1
Powered by blists - more mailing lists