From patchwork Tue Jan 3 13:12:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9494837 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 26F47606B5 for ; Tue, 3 Jan 2017 13:15:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 140B827031 for ; Tue, 3 Jan 2017 13:15:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08D7226E8A; Tue, 3 Jan 2017 13:15:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DA8C27165 for ; Tue, 3 Jan 2017 13:15:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932179AbdACNMr (ORCPT ); Tue, 3 Jan 2017 08:12:47 -0500 Received: from mail.kernel.org ([198.145.29.136]:36626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757376AbdACNMf (ORCPT ); Tue, 3 Jan 2017 08:12:35 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B055204EA; Tue, 3 Jan 2017 13:12:33 +0000 (UTC) Received: from CookieMonster.cookiemonster.local (cpc89244-aztw30-2-0-cust5770.18-1.cable.virginm.net [86.31.182.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7A06D203E3; Tue, 3 Jan 2017 13:12:30 +0000 (UTC) From: Kieran Bingham To: sakari.ailus@iki.fi, laurent.pinchart@ideasonboard.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Kieran Bingham Subject: [PATCH] media: entity: Catch unbalanced media_pipeline_stop calls Date: Tue, 3 Jan 2017 13:12:11 +0000 Message-Id: <1483449131-18075-1-git-send-email-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Laurent Pinchart --- drivers/media/media-entity.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index caa13e6f09f5..cb1fb2c17f85 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -534,8 +534,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))) {