aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2016-05-18 19:01:21 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-06-28 10:59:43 -0400
commitd69e40fade97b6b19837c1772efa516bc28cc870 (patch)
tree7e2dd33b0069729777f245f0bd782203676f58bc
parent398e3d4f1e0baecb926315673a6740f2573b07ae (diff)
[media] v4l: vsp1: Fix crash when resetting pipeline
The vsp1_pipeline_reset() function loops over pipeline inputs and output and resets them. When doing so it assumes both that the pipeline has been correctly configured with an output, and that inputs are are stored in the pipe inputs array at positions 0 to num_inputs-1. Both the assumptions are incorrect. The pipeline might need to be reset after a failed attempts to configure it, without any output specified. Furthermore, inputs are stored in a positiong equal to their RPF index, possibly creating holes in the inputs array if the RPFs are not used in sequence. Fix both issues by looping over the whole inputs array and skipping unused entries, and ignoring the output when not set. Fixes: ff7e97c94d9f ("[media] v4l: vsp1: Store pipeline pointer in rwpf") Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/platform/vsp1/vsp1_pipe.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c b/drivers/media/platform/vsp1/vsp1_pipe.c
index be47c8a1a812..3c6f623f056c 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.c
+++ b/drivers/media/platform/vsp1/vsp1_pipe.c
@@ -172,13 +172,17 @@ void vsp1_pipeline_reset(struct vsp1_pipeline *pipe)
172 bru->inputs[i].rpf = NULL; 172 bru->inputs[i].rpf = NULL;
173 } 173 }
174 174
175 for (i = 0; i < pipe->num_inputs; ++i) { 175 for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) {
176 pipe->inputs[i]->pipe = NULL; 176 if (pipe->inputs[i]) {
177 pipe->inputs[i] = NULL; 177 pipe->inputs[i]->pipe = NULL;
178 pipe->inputs[i] = NULL;
179 }
178 } 180 }
179 181
180 pipe->output->pipe = NULL; 182 if (pipe->output) {
181 pipe->output = NULL; 183 pipe->output->pipe = NULL;
184 pipe->output = NULL;
185 }
182 186
183 INIT_LIST_HEAD(&pipe->entities); 187 INIT_LIST_HEAD(&pipe->entities);
184 pipe->state = VSP1_PIPELINE_STOPPED; 188 pipe->state = VSP1_PIPELINE_STOPPED;