diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2018-09-10 11:00:39 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-09-24 09:09:07 -0400 |
commit | d61b3b41014df01ef96a07a973ea56f55abfbe74 (patch) | |
tree | f9ea4f0170b335cfe68808aa8ca89ccf8cde8449 /drivers/media/platform/vicodec | |
parent | 0113c50f425f953f2abe56d228c52622c859c4ad (diff) | |
download | lwn-d61b3b41014df01ef96a07a973ea56f55abfbe74.tar.gz lwn-d61b3b41014df01ef96a07a973ea56f55abfbe74.zip |
media: vicodec: check for valid format in v4l2_fwht_en/decode
These functions did not return an error if state->info was NULL
or an unsupported pixelformat was selected (should not happen,
but just to be on the safe side).
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/platform/vicodec')
-rw-r--r-- | drivers/media/platform/vicodec/codec-v4l2-fwht.c | 15 | ||||
-rw-r--r-- | drivers/media/platform/vicodec/codec-v4l2-fwht.h | 7 |
2 files changed, 13 insertions, 9 deletions
diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.c b/drivers/media/platform/vicodec/codec-v4l2-fwht.c index 6b06aa382cbb..e5b68fb38aac 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.c +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.c @@ -51,8 +51,7 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx) return v4l2_fwht_pixfmts + idx; } -unsigned int v4l2_fwht_encode(struct v4l2_fwht_state *state, - u8 *p_in, u8 *p_out) +int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) { unsigned int size = state->width * state->height; const struct v4l2_fwht_pixfmt_info *info = state->info; @@ -62,6 +61,8 @@ unsigned int v4l2_fwht_encode(struct v4l2_fwht_state *state, u32 encoding; u32 flags = 0; + if (!info) + return -EINVAL; rf.width = state->width; rf.height = state->height; rf.luma = p_in; @@ -137,6 +138,8 @@ unsigned int v4l2_fwht_encode(struct v4l2_fwht_state *state, rf.cr = rf.cb + 2; rf.luma++; break; + default: + return -EINVAL; } cf.width = state->width; @@ -180,8 +183,7 @@ unsigned int v4l2_fwht_encode(struct v4l2_fwht_state *state, return cf.size + sizeof(*p_hdr); } -int v4l2_fwht_decode(struct v4l2_fwht_state *state, - u8 *p_in, u8 *p_out) +int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) { unsigned int size = state->width * state->height; unsigned int chroma_size = size; @@ -191,6 +193,9 @@ int v4l2_fwht_decode(struct v4l2_fwht_state *state, struct fwht_cframe cf; u8 *p; + if (!state->info) + return -EINVAL; + p_hdr = (struct fwht_cframe_hdr *)p_in; cf.width = ntohl(p_hdr->width); cf.height = ntohl(p_hdr->height); @@ -320,6 +325,8 @@ int v4l2_fwht_decode(struct v4l2_fwht_state *state, *p++ = 0; } break; + default: + return -EINVAL; } return 0; } diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.h b/drivers/media/platform/vicodec/codec-v4l2-fwht.h index 95d1756556db..162465b78067 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.h +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.h @@ -41,10 +41,7 @@ struct v4l2_fwht_state { const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_pixfmt(u32 pixelformat); const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx); -unsigned int v4l2_fwht_encode(struct v4l2_fwht_state *state, - u8 *p_in, u8 *p_out); - -int v4l2_fwht_decode(struct v4l2_fwht_state *state, - u8 *p_in, u8 *p_out); +int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out); +int v4l2_fwht_decode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out); #endif |