From patchwork Fri Mar 10 04:32:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9614711 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 0189760415 for ; Fri, 10 Mar 2017 04:42:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7659271E0 for ; Fri, 10 Mar 2017 04:42:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC20127B13; Fri, 10 Mar 2017 04:42:26 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 73F2C271E0 for ; Fri, 10 Mar 2017 04:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=m8cjvHX5XaofP7bLLrH3tLLpAdAsOLqRvcBi2eao4Fg=; b=i4CM0w0AA7WFrUX650J1fSVMVP VLEZ8dphPYs+70LrIAYIijr0TceFpm2HmMb6QLJUdEVxJtLJSc5OTEj07U3jHa7o2n2QjMy7ICYgb 3B5IaPUnU6JSGl4VYpq0Mga1z+5znAE+WHt+F4pS9WW6gVhINWnhUWwIk4IYcaNw+Kw822T4kYLre vN5WzGm2/wqsahQgZuSQD3qb3fOzCiEUKOr9kS+vvt4NM8KXFfJIYKVDtz8latfcMI3hz4Un6zwYP MqyEPbGbFdkOtci1oWujHwblIF1ZOx3Sf25zaOwf/ON8llQ59z8Tyk7c+GwCH3rBHuE6dC3RZ4vUl y0KEMCog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cmCNl-0005KR-QY; Fri, 10 Mar 2017 04:42:25 +0000 Received: from mail-qk0-x229.google.com ([2607:f8b0:400d:c09::229]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cmCNb-00051K-Kw for linux-rockchip@lists.infradead.org; Fri, 10 Mar 2017 04:42:23 +0000 Received: by mail-qk0-x229.google.com with SMTP id v125so149004105qkh.2 for ; Thu, 09 Mar 2017 20:41:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WHomiS/PbRiEf0U8xGYIZzY9J91zDW4ixsMPEcfUKfs=; b=WXbfUoSDOw6ReSmI+5QWTcEkNFOQ0hO8qHKgy8lL9cshMGmKqsdJtWLQYgsJ28OMZr BSGe+a+yE9kljKJf27uUqAPwW6xBmr+tYXM0acDPfoUojEJk8508jAw0DmOm2nGswYM6 d1AhYyreDdrEpogl3Jb/cW7xMiJiGT5987vVU= 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=WHomiS/PbRiEf0U8xGYIZzY9J91zDW4ixsMPEcfUKfs=; b=G1A3U/pYk2b7RzTpSiegK5MAml3GIbbSjGLCDRtBE9u/Pofj20TvG0AHenNB8jpV4C f/U8Uj98qUP4Inc5rLtK30nRA1gw4HxiA8PSi0aeNSSBiLYRe53Ga4RGIksVB7m4GHmR 7fXTW5hdHhVje0QEYkxOuBFpaEPT7YTyJ1KH+Fs+bTul9ISIUqrbc6TikU72cRUNswwL FlHGHiM+bNz+fPMkai6lvGmshvAT9Quu7CDVD50BurxxL+e/ZjArgW5jI4fHUdG9x1+P cq+oh6jU41BrBWy5EPkwvpAKNg9K5o+Reg3fYqWaBOH+s3ZqKJnhw88Qmd+M9EZl/TgA yq7g== X-Gm-Message-State: AFeK/H3Mnt9db/htvIoTNZBQPZkDcQ3JS3vWDSPaIbguWwtu8+vRj+qs8Vrjkn2/ETZ1xVtE X-Received: by 10.55.69.68 with SMTP id s65mr17043443qka.43.1489120914752; Thu, 09 Mar 2017 20:41:54 -0800 (PST) Received: from boxwood.roam.corp.google.com (cpe-75-189-128-87.nc.res.rr.com. [75.189.128.87]) by smtp.gmail.com with ESMTPSA id n19sm5697731qtn.35.2017.03.09.20.41.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 20:41:53 -0800 (PST) From: Sean Paul To: linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH 35/41] drm/rockchip: analogix_dp: Fix invalid implementation of unbind Date: Thu, 9 Mar 2017 23:32:50 -0500 Message-Id: <20170310043305.17216-36-seanpaul@chromium.org> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog In-Reply-To: <20170310043305.17216-1-seanpaul@chromium.org> References: <20170310043305.17216-1-seanpaul@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170309_204216_220879_A08A439E X-CRM114-Status: GOOD ( 10.80 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , David Airlie , Brian Norris , Tomasz Figa , Sean Paul , "Kristian H . Kristensen" , linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tomasz Figa Current implementation of unbind dereferences the drvdata pointer assuming that it's its own data, however the ownership belongs to the analogix code, which means that the pointer is dereferenced with wrong type. Fix this by using the recently added platform data .cleanup() callback to do Rockchip-specific things at unbind. Cc: Kristian H. Kristensen Cc: Brian Norris Signed-off-by: Tomasz Figa Signed-off-by: Sean Paul --- drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index de23cc6fd05d..0a92d9e3ffac 100644 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c @@ -179,6 +179,13 @@ static int rockchip_dp_get_modes(struct analogix_dp_plat_data *plat_data, return 0; } +static void rockchip_dp_cleanup(struct analogix_dp_plat_data *plat_data) +{ + struct rockchip_dp_device *dp = to_dp(plat_data); + + rockchip_drm_psr_unregister(&dp->encoder); +} + static bool rockchip_dp_drm_encoder_mode_fixup(struct drm_encoder *encoder, const struct drm_display_mode *mode, @@ -395,25 +402,16 @@ static int rockchip_dp_bind(struct device *dev, struct device *master, dp->plat_data.power_on = rockchip_dp_poweron; dp->plat_data.power_off = rockchip_dp_powerdown; dp->plat_data.get_modes = rockchip_dp_get_modes; + dp->plat_data.cleanup = rockchip_dp_cleanup; rockchip_drm_psr_register(&dp->encoder, analogix_dp_psr_set); return analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data); } -static void rockchip_dp_unbind(struct device *dev, struct device *master, - void *data) -{ - struct rockchip_dp_device *dp = dev_get_drvdata(dev); - - rockchip_drm_psr_unregister(&dp->encoder); - - return analogix_dp_unbind(dev, master, data); -} - static const struct component_ops rockchip_dp_component_ops = { .bind = rockchip_dp_bind, - .unbind = rockchip_dp_unbind, + .unbind = analogix_dp_unbind, }; static int rockchip_dp_probe(struct platform_device *pdev)