Skip to content

Commit

Permalink
media: cetrus: return an error if alloc fails
Browse files Browse the repository at this point in the history
As warned by smatch:

	drivers/staging/media/sunxi/cedrus/cedrus.c: drivers/staging/media/sunxi/cedrus/cedrus.c:93 cedrus_init_ctrls() error: potential null dereference 'ctx->ctrls'.  (kzalloc returns null)

While here, remove the memset(), as kzalloc() already zeroes the
struct.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
  • Loading branch information
Mauro Carvalho Chehab committed Dec 7, 2018
1 parent e82a34f commit 9ed5d5f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/staging/media/sunxi/cedrus/cedrus.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ static int cedrus_init_ctrls(struct cedrus_dev *dev, struct cedrus_ctx *ctx)
ctrl_size = sizeof(ctrl) * CEDRUS_CONTROLS_COUNT + 1;

ctx->ctrls = kzalloc(ctrl_size, GFP_KERNEL);
memset(ctx->ctrls, 0, ctrl_size);
if (!ctx->ctrls)
return -ENOMEM;

for (i = 0; i < CEDRUS_CONTROLS_COUNT; i++) {
struct v4l2_ctrl_config cfg = { 0 };
Expand Down

0 comments on commit 9ed5d5f

Please sign in to comment.