From 2a2599c663684a1142dae0bff7737e125891ae6d Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Tue, 3 Jan 2017 11:12:11 -0200 Subject: [media] media: entity: Catch unbalanced media_pipeline_stop calls Drivers must not perform unbalanced calls to stop the entity pipeline, however if they do they will fault in the core media code, as the entity->pipe will be set as NULL. We handle this gracefully in the core with a WARN for the developer. Replace the erroneous check on zero streaming counts, with a check on NULL pipe elements instead, as this is the symptom of unbalanced media_pipeline_stop calls. Signed-off-by: Kieran Bingham Signed-off-by: Laurent Pinchart Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/media/media-entity.c') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 82d6755bd5d0..dd0f0ead9516 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -566,8 +566,13 @@ void __media_pipeline_stop(struct media_entity *entity) struct media_graph *graph = &entity->pipe->graph; struct media_pipeline *pipe = entity->pipe; + /* + * If the following check fails, the driver has performed an + * unbalanced call to media_pipeline_stop() + */ + if (WARN_ON(!pipe)) + return; - WARN_ON(!pipe->streaming_count); media_graph_walk_start(graph, entity); while ((entity = media_graph_walk_next(graph))) { -- cgit v1.2.1