summaryrefslogtreecommitdiff
path: root/drivers/media/test-drivers/vidtv/vidtv_s302m.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-09-21 16:11:50 +0300
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-11-26 09:43:40 +0300
commit3be8037960bccd13052cfdeba8805ad785041d70 (patch)
tree61a614288890ceac66534306df68cf583360be42 /drivers/media/test-drivers/vidtv/vidtv_s302m.c
parent8922e3931dd79055bb3f851bed33f069fc67a2fc (diff)
downloadlinux-3be8037960bccd13052cfdeba8805ad785041d70.tar.xz
media: vidtv: add error checks
Currently, there are not checks if something gets bad during memory allocation: it will simply use NULL pointers and crash. Add error path at the logic which allocates memory for the MPEG-TS generator code, propagating the errors up to the vidtv_bridge. Now, if something wents bad, start_streaming will return an error that userspace can detect: ERROR DMX_SET_PES_FILTER failed (PID = 0x2000): 12 Cannot allocate memory and the driver doesn't crash. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/test-drivers/vidtv/vidtv_s302m.c')
-rw-r--r--drivers/media/test-drivers/vidtv/vidtv_s302m.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.c b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
index ec88af63a74e..146e4e9d361b 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_s302m.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
@@ -144,7 +144,11 @@ static const struct tone_duration beethoven_5th_symphony[] = {
static struct vidtv_access_unit *vidtv_s302m_access_unit_init(struct vidtv_access_unit *head)
{
- struct vidtv_access_unit *au = kzalloc(sizeof(*au), GFP_KERNEL);
+ struct vidtv_access_unit *au;
+
+ au = kzalloc(sizeof(*au), GFP_KERNEL);
+ if (!au)
+ return NULL;
if (head) {
while (head->next)
@@ -441,9 +445,13 @@ static u32 vidtv_s302m_clear(struct vidtv_encoder *e)
struct vidtv_encoder
*vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args)
{
- struct vidtv_encoder *e = kzalloc(sizeof(*e), GFP_KERNEL);
+ struct vidtv_encoder *e;
u32 priv_sz = sizeof(struct vidtv_s302m_ctx);
- struct vidtv_s302m_ctx *ctx = kzalloc(priv_sz, GFP_KERNEL);
+ struct vidtv_s302m_ctx *ctx;
+
+ e = kzalloc(sizeof(*e), GFP_KERNEL);
+ if (!e)
+ return NULL;
e->id = S302M;
@@ -461,6 +469,11 @@ struct vidtv_encoder
e->src_buf_offset = 0;
e->is_video_encoder = false;
+
+ ctx = kzalloc(priv_sz, GFP_KERNEL);
+ if (!ctx)
+ return NULL;
+
e->ctx = ctx;
ctx->last_duration = 0;