]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: vicodec: fix memchr() kernel oops
authorHans Verkuil <hverkuil@xs4all.nl>
Sat, 17 Nov 2018 11:25:08 +0000 (06:25 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Dec 2018 08:16:17 +0000 (09:16 +0100)
commit cb3b2ffb757e75fef40fb94bc093cbbf49a6bf6e upstream.

The size passed to memchr is too large as it assumes the search
starts at the start of the buffer, but it can start at an offset.

Cc: <stable@vger.kernel.org> # for v4.19 and up
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/platform/vicodec/vicodec-core.c

index daa5caa6adc6d816bc2ac604341b283af0ece6b2..7a33a52eaccaa99c159f23058f7c1636f01d5b9d 100644 (file)
@@ -438,7 +438,8 @@ restart:
                for (; p < p_out + sz; p++) {
                        u32 copy;
 
-                       p = memchr(p, magic[ctx->comp_magic_cnt], sz);
+                       p = memchr(p, magic[ctx->comp_magic_cnt],
+                                  p_out + sz - p);
                        if (!p) {
                                ctx->comp_magic_cnt = 0;
                                break;