diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2018-08-23 10:10:05 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-08-31 14:30:46 +0200 |
commit | be5a1509af8dd8a78fea24a35fe4a82d4cd0ae70 (patch) | |
tree | d7a3a184ca868cb17c8abb8097f840ff11ef317d /drivers/media/platform/vicodec | |
parent | media: vicodec: split off v4l2 specific parts for the codec (diff) | |
download | linux-be5a1509af8dd8a78fea24a35fe4a82d4cd0ae70.tar.xz linux-be5a1509af8dd8a78fea24a35fe4a82d4cd0ae70.zip |
media: vicodec: fix out-of-range values when decoding
While decoding you need to make sure you do not get values < 0
or > 255. Note that since this code will also be used in userspace
utilities the clamp macro isn't used since that is kernel-only.
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-fwht.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/media/platform/vicodec/codec-fwht.c b/drivers/media/platform/vicodec/codec-fwht.c index f91f90f7e5fc..47939160560e 100644 --- a/drivers/media/platform/vicodec/codec-fwht.c +++ b/drivers/media/platform/vicodec/codec-fwht.c @@ -625,8 +625,14 @@ static void fill_decoder_block(u8 *dst, const s16 *input, int stride) int i, j; for (i = 0; i < 8; i++) { - for (j = 0; j < 8; j++) - *dst++ = *input++; + for (j = 0; j < 8; j++, input++, dst++) { + if (*input < 0) + *dst = 0; + else if (*input > 255) + *dst = 255; + else + *dst = *input; + } dst += stride - 8; } } |