Commit fa0b5658 authored by Tom Rix's avatar Tom Rix Committed by Mauro Carvalho Chehab

media: ti-vpe: cal: fix indexing of cal->ctx[] in cal_probe()

cal->ctx[i] is allocated with this loop
	for (i = 0; i < cal->data->num_csi2_phy; ++i) {
and accessed in the error handler and else where with this loop
	for (i = 0; i < cal->num_contexts; i++)
Because the first loop contains a continue statement
before cal->num_contexts is incremented, using i as the
indexer will leave gaps in the cal->ctx[].

So use cal->num_contexts as the indexer.

Fixes: 75e7e58b ("media: ti-vpe: cal: support 8 DMA contexts")
Signed-off-by: default avatarTom Rix <trix@redhat.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent e58430e1
......@@ -1148,9 +1148,9 @@ static int cal_probe(struct platform_device *pdev)
if (!cal->phy[i]->source_node)
continue;
cal->ctx[i] = cal_ctx_create(cal, i);
if (!cal->ctx[i]) {
cal_err(cal, "Failed to create context %u\n", i);
cal->ctx[cal->num_contexts] = cal_ctx_create(cal, i);
if (!cal->ctx[cal->num_contexts]) {
cal_err(cal, "Failed to create context %u\n", cal->num_contexts);
ret = -ENODEV;
goto error_context;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment