Skip to content

Commit

Permalink
media: coda: jpeg: add NULL check after kmalloc
Browse files Browse the repository at this point in the history
[ Upstream commit 2017172 ]

Fixes coccicheck warning:

./drivers/media/platform/coda/coda-jpeg.c:331:3-31:
	alloc with no test, possible model on line 354

Add NULL check after kmalloc.

Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Chen Zhou authored and gregkh committed Aug 26, 2020
1 parent cd67c59 commit 527b13f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/media/platform/coda/coda-jpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,11 @@ int coda_jpeg_decode_header(struct coda_ctx *ctx, struct vb2_buffer *vb)
"only 8-bit quantization tables supported\n");
continue;
}
if (!ctx->params.jpeg_qmat_tab[i])
if (!ctx->params.jpeg_qmat_tab[i]) {
ctx->params.jpeg_qmat_tab[i] = kmalloc(64, GFP_KERNEL);
if (!ctx->params.jpeg_qmat_tab[i])
return -ENOMEM;
}
memcpy(ctx->params.jpeg_qmat_tab[i],
quantization_tables[i].start, 64);
}
Expand Down

0 comments on commit 527b13f

Please sign in to comment.