Skip to content

Commit 441c054

Browse files
JiangJiasgregkh
authored andcommitted
media: coda: Add check for kmalloc
[ Upstream commit 6e5e5de ] As the kmalloc may return NULL pointer, it should be better to check the return value in order to avoid NULL poineter dereference, same as the others. Fixes: cb1d3a3 ("[media] coda: add CODA7541 JPEG support") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b998721 commit 441c054

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/media/platform/coda/coda-bit.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,10 +1082,16 @@ static int coda_start_encoding(struct coda_ctx *ctx)
10821082
}
10831083

10841084
if (dst_fourcc == V4L2_PIX_FMT_JPEG) {
1085-
if (!ctx->params.jpeg_qmat_tab[0])
1085+
if (!ctx->params.jpeg_qmat_tab[0]) {
10861086
ctx->params.jpeg_qmat_tab[0] = kmalloc(64, GFP_KERNEL);
1087-
if (!ctx->params.jpeg_qmat_tab[1])
1087+
if (!ctx->params.jpeg_qmat_tab[0])
1088+
return -ENOMEM;
1089+
}
1090+
if (!ctx->params.jpeg_qmat_tab[1]) {
10881091
ctx->params.jpeg_qmat_tab[1] = kmalloc(64, GFP_KERNEL);
1092+
if (!ctx->params.jpeg_qmat_tab[1])
1093+
return -ENOMEM;
1094+
}
10891095
coda_set_jpeg_compression_quality(ctx, ctx->params.jpeg_quality);
10901096
}
10911097

0 commit comments

Comments
 (0)