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: 9614715 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 5900B60415 for ; Fri, 10 Mar 2017 04:42:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BDAA2865E for ; Fri, 10 Mar 2017 04:42:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40C84286EF; Fri, 10 Mar 2017 04:42:30 +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=unavailable 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 F2F8C2865E for ; Fri, 10 Mar 2017 04:42:29 +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=1yspUEokpGO3jXh0bJSK/BhqnGaZx8XB8MbwYUy2ZN4=; b=uqBjG92kg6r+Emd9bZ1EfU7jwc RWk6y9XEMdsB4HHA1A2ry7awepIr1r0BVmL+pBpqlxakUxg12pKFhRXow0+FCp43AkTcAGyrwWoJH IFR37u931wv6mPM8vaK3r9iLWSCpZWSs0Tej+XuaWZ6TZVaYVhkHDEqNxfNZXdRO0h7p8RrAhkbEN JDW/B1zAc7T2TL2Msis1zM1aD0MvL8fE3uGy4p7Tpqjf6RXCoSR2UBFVcgBpIpTjWNQXa2BcsMb6S E/aCsc/R7Wd3p12rwuLyqnhHp+uEqkhuhGVYLDB7kb5ZGTVmdarMdRrAyWYYXKfjhdGCZjp92yocL XgeiTKcA==; 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 1cmCNm-0005L7-Vf; Fri, 10 Mar 2017 04:42:26 +0000 Received: from mail-qk0-x22b.google.com ([2607:f8b0:400d:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cmCNb-00051L-IX for linux-arm-kernel@lists.infradead.org; Fri, 10 Mar 2017 04:42:23 +0000 Received: by mail-qk0-x22b.google.com with SMTP id p64so152367920qke.1 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=f6PKJY7n+Ij9Y2SwQGWdRhGxFwdUAcD4XNja8sDiNcdu8olauDlyHQG/zgxzQcPlxl Mvc1Wg3eD9aaDSrH9Svpofvmd78hWCv1ripBk3UTgIJjPF5sWk9br0+HVwWjD+AzsvSy ZC9GYPpZDLQAb61aYAuM3z55pU3lCMjHzYCnhSkXeqCjITesD1vQWq3e6kZhsRno8lCK OBKzTjCPMmaTda6Or1yeTJIfTFjqSPby77lsEnJTWh/j1sIGnzVSVvkdIm5M4AweKnyk SFRBpWkM9B09Elf6LeDfQUC/Jqs9KaMH/97CFoZgLl7gNJN/Vr1CVIJGlw3AgSNutSjI zn0A== X-Gm-Message-State: AFeK/H3CCkV49GKGP6eDs3Xla3tQc93TqRLC5D/sRnwNJHiBIZPWfbDKMyG5YyO4UEjbdxhF 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_240773_CC4B337C X-CRM114-Status: GOOD ( 12.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: 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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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)