From patchwork Fri Sep 29 12:59:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 9977975 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 26A8460311 for ; Fri, 29 Sep 2017 12:59:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1676829868 for ; Fri, 29 Sep 2017 12:59:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B1E12986A; Fri, 29 Sep 2017 12:59:37 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C62F329868 for ; Fri, 29 Sep 2017 12:59:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F334E6EB83; Fri, 29 Sep 2017 12:59:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3D4216EB83 for ; Fri, 29 Sep 2017 12:59:34 +0000 (UTC) Received: by mail-wm0-x232.google.com with SMTP id m72so3241025wmc.1 for ; Fri, 29 Sep 2017 05:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+6qTWk2NQHqkPJUR4egv7WzZ0oLeBPdJGWCoL/5D6Tw=; b=IKt5Jr7jQIVrUD4KGoRo2lDM6SCgWcMosXVwBzFx2M5p/wss/Q4OlNgZxHMQfDmhfd KiayiNOLQQ9fnkB60q9HhZUcUKL135SKMdfzteMp9yOOL1/jArPePnq35mso+WrqYp8H O7n3Y+dEISs7me+pkOZq8wWUwmLcYReovgcqE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+6qTWk2NQHqkPJUR4egv7WzZ0oLeBPdJGWCoL/5D6Tw=; b=Kn0b+kAZmqSMr/jm1Okph8j950nfVffwygSr+dd+/mTIz0PcWOgz0AMbX1RlbjoKJ8 HJLqKfFdyymte8x3/0Ai/nZ4PWTlxdzXQ54yWt9P4Gwc75Qj1/H4wR/4VP9YGBXf06vf YB/+CvTmvZBozxPQKwqdVQ4KgxZ/8TWYpt/FbWdw1neifUfck+q5iNUBizejrbZWF3Nu OA5P9JXdwvgdvPcT5hiHmRsprUyJjnqoyhuX5d0/taANw2YJMYu0zhb//PXaFYjHNLdP WDM8xgVYCk16M74tObF8mzjjkFpYwfd2g9YLXrpN4MLIZ/5JktrFw81o7ULDJ9rLgOSX gVMg== X-Gm-Message-State: AHPjjUh1N1oEWyljTQufE3ljMuB1C59cQBcxLSeWGPR23VeaCIxRf2aC Lfq0Qo3jSB/mTHXcsW+18Wrraw== X-Google-Smtp-Source: AOwi7QDESy5y8I6ddDl0HbbclKxo22GAEamNZ5l03A/yR94jBcOdaOZoYdxJdGipwpPbngFOJHe6wA== X-Received: by 10.28.63.145 with SMTP id m139mr4496254wma.5.1506689972620; Fri, 29 Sep 2017 05:59:32 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.91.35]) by smtp.gmail.com with ESMTPSA id k11sm3269667wrc.90.2017.09.29.05.59.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Sep 2017 05:59:32 -0700 (PDT) From: Benjamin Gaignard To: architt@codeaurora.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, airlied@linux.ie, daniel.vetter@intel.com, jani.nikula@linux.intel.com, seanpaul@chromium.org, yannick.fertre@st.com, philippe.cornu@st.com Subject: [PATCH 1/3] drm/bridge: make drm_panel_bridge_remove more robust Date: Fri, 29 Sep 2017 14:59:17 +0200 Message-Id: <1506689959-7858-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506689959-7858-1-git-send-email-benjamin.gaignard@linaro.org> References: <1506689959-7858-1-git-send-email-benjamin.gaignard@linaro.org> Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Make sure that bridge parameter is not NULL and can be safely cast into a panel_bridge structure. Signed-off-by: Benjamin Gaignard --- drivers/gpu/drm/bridge/panel.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index e0cca19..6d99d4a 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -188,7 +188,15 @@ EXPORT_SYMBOL(drm_panel_bridge_add); */ void drm_panel_bridge_remove(struct drm_bridge *bridge) { - struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge); + struct panel_bridge *panel_bridge; + + if (!bridge) + return; + + if (bridge->funcs != &panel_bridge_bridge_funcs) + return; + + panel_bridge = drm_bridge_to_panel_bridge(bridge); drm_bridge_remove(bridge); devm_kfree(panel_bridge->panel->dev, bridge);