From patchwork Mon Oct 2 09:32:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 9980539 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 B8EF1602A0 for ; Mon, 2 Oct 2017 09:32:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AACF42891F for ; Mon, 2 Oct 2017 09:32:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F25F289BB; Mon, 2 Oct 2017 09:32:57 +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 20BD62891F for ; Mon, 2 Oct 2017 09:32:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D3FAE6E2E5; Mon, 2 Oct 2017 09:32:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x229.google.com (mail-wr0-x229.google.com [IPv6:2a00:1450:400c:c0c::229]) by gabe.freedesktop.org (Postfix) with ESMTPS id C6E086E2E5 for ; Mon, 2 Oct 2017 09:32:53 +0000 (UTC) Received: by mail-wr0-x229.google.com with SMTP id l39so3429221wrl.12 for ; Mon, 02 Oct 2017 02:32:53 -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=FGwwx0p8yLoQ/Wgw+XVB6XyVdxOVWkNkRP1/Mk0nWlw=; b=U7DQQgCXsg0eviLFaIu+XjVczHYnu8msvMibBaPaiFJslFumjNIauKaq+nwATIa83F tzrjlpF88Fozp0MTe5uuQyfX3PVGwqCOMAPXtuXjwAAm6tCF8Xn+4w9bcv9fttD0Ll+k rXe/YVbIqT+xzIxOXmPDlMNlZtelrlcPrnAAs= 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=FGwwx0p8yLoQ/Wgw+XVB6XyVdxOVWkNkRP1/Mk0nWlw=; b=dwV/KTXgELFJdWGR5/MlbPdIlNwbpAcrI/1KTSqIvQocJ4+7OwQqLbzMOI3tYVM5ly 6hjohVjU5ur+a30xZ9oBLtQK5IxJ2BtqFZ045Q3PnS1Gb9YSj/inHsHkq3F8dyvJ2gLY KsCFs2S2gNwQ9SMxXU1lRt2CmSRru/HwxqKj0j3o9zneaihjI4PPpvYI7VseMAsczqBO qhwjfEOaN9XirKNJDw4Dt5XMHuHYmD7SyUxNebWss7TZnvH3/NvIH712ATzKLsCMen27 9bQcYs9I+1Pq7x2D3m0xPiHPCVti5Rr8eJI6khPu2vwk5OBA9gdRiZIko2VfrHphHlii C2Rw== X-Gm-Message-State: AHPjjUjX+WNvwNqgPaz8dsnl9cMZi7yAqWmQpOE7R55V3QQph7RSKVIM bhpg0dKkxO/tC3Tj7D0ABgNKuQ== X-Google-Smtp-Source: AOwi7QAW2LUV9x42XtxV2FuOftZoQjk+zPfLShqxa9Qn06CFs4Bko2+oCKyrzQFShs3tggo0lzahyg== X-Received: by 10.223.139.212 with SMTP id w20mr13180406wra.275.1506936772338; Mon, 02 Oct 2017 02:32:52 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.199.139]) by smtp.gmail.com with ESMTPSA id 64sm4773434wma.21.2017.10.02.02.32.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Oct 2017 02:32:51 -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 v2 1/5] drm/bridge: make drm_panel_bridge_remove more robust Date: Mon, 2 Oct 2017 11:32:31 +0200 Message-Id: <1506936755-23625-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506936755-23625-1-git-send-email-benjamin.gaignard@linaro.org> References: <1506936755-23625-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 Reviewed-by: Philippe Cornu Tested-by: Philippe Cornu --- 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);