Skip to content

Commit 6e5e5de

Browse files
JiangJiasHans Verkuil
authored andcommitted
media: coda: Add check for kmalloc
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 <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 6b80822 commit 6e5e5de

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

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

10861086
if (dst_fourcc == V4L2_PIX_FMT_JPEG) {
1087-
if (!ctx->params.jpeg_qmat_tab[0])
1087+
if (!ctx->params.jpeg_qmat_tab[0]) {
10881088
ctx->params.jpeg_qmat_tab[0] = kmalloc(64, GFP_KERNEL);
1089-
if (!ctx->params.jpeg_qmat_tab[1])
1089+
if (!ctx->params.jpeg_qmat_tab[0])
1090+
return -ENOMEM;
1091+
}
1092+
if (!ctx->params.jpeg_qmat_tab[1]) {
10901093
ctx->params.jpeg_qmat_tab[1] = kmalloc(64, GFP_KERNEL);
1094+
if (!ctx->params.jpeg_qmat_tab[1])
1095+
return -ENOMEM;
1096+
}
10911097
coda_set_jpeg_compression_quality(ctx, ctx->params.jpeg_quality);
10921098
}
10931099

0 commit comments

Comments
 (0)