diff options
author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2021-03-04 14:45:20 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2021-03-22 10:17:56 +0100 |
commit | b83209176d6892ea2e086d0f1d45fdd1cf5f8569 (patch) | |
tree | b37ad5c16bd787dc65b5c7bbd02dc0b420bd004e /drivers | |
parent | f9426edd5668ddc9bcc199721bf693efdfa92f0e (diff) |
media: ti-vpe: cal: fix subdev mbus_code enumeration
The cal_ctx_v4l2_init_formats() function does not handle error values
correctly when calling enum_mbus_code in subdevs, causing an infinite
loop if the subdev's enum_mbus_code returns some other error than EINVAL.
Fix the error handling.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/platform/ti-vpe/cal-video.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/media/platform/ti-vpe/cal-video.c b/drivers/media/platform/ti-vpe/cal-video.c index 47bea40c64c2..09a47a486215 100644 --- a/drivers/media/platform/ti-vpe/cal-video.c +++ b/drivers/media/platform/ti-vpe/cal-video.c @@ -591,15 +591,21 @@ static int cal_ctx_v4l2_init_formats(struct cal_ctx *ctx) sizeof(*ctx->active_fmt), GFP_KERNEL); ctx->num_active_fmt = 0; - for (j = 0, i = 0; ret != -EINVAL; ++j) { + for (j = 0, i = 0; ; ++j) { memset(&mbus_code, 0, sizeof(mbus_code)); mbus_code.index = j; mbus_code.which = V4L2_SUBDEV_FORMAT_ACTIVE; ret = v4l2_subdev_call(ctx->phy->sensor, pad, enum_mbus_code, NULL, &mbus_code); - if (ret) - continue; + if (ret == -EINVAL) + break; + + if (ret) { + ctx_err(ctx, "Error enumerating mbus codes in subdev %s: %d\n", + ctx->phy->sensor->name, ret); + return ret; + } ctx_dbg(2, ctx, "subdev %s: code: %04x idx: %u\n", |