Received: by 10.192.165.156 with SMTP id m28csp2115643imm; Thu, 12 Apr 2018 08:52:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx484YANK0IHaKtSlFZT4JCk7StSVeEAXvr4vNhIsiVuorwJ3tUPx/YodGnuvSXWHD5DwdZqF X-Received: by 10.99.125.87 with SMTP id m23mr1076064pgn.297.1523548333237; Thu, 12 Apr 2018 08:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523548333; cv=none; d=google.com; s=arc-20160816; b=TAjAfAN0laRTPj9vEIVmJ7QlFyh7iJCFZvLkjuLc+ShQfTMfWsHACTTB/PbP8fjkpY aPqOiwGvnNZv2HrB6SOuwjsIZjQMDEPVjfCOKzM/VgraaNqA/rtL+NrgDJCURKGdS/8x Nhu1cQagUByn6gpe2JEnyFG2DavRpauG/qVU2JierZauC96xf2N4/g5id/MW+Uhv3qxH kbH/v7OjQZIasIOHymetnea2xMfNkv5qKLGjKkaexGRBvEWszI+vj8oRacG/HkIw0JUm 9mRSzTtiwfjjjdFKChoMP1pFBxib6isNCvw8oFuWYOjFL5TU1UU4DWjG5KamHTtBSajc S0Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=shy+p644cloQheMNP7a2FhDIoWo1PBlen3TlO/hIPJQ=; b=gBk6MtBIXNAO4OV3AuHpwv3sBHf0F9jP+oVVr+tSAJ3bwFjFthCQocFuUdklPk6uH0 J1gEviWMOCx8DP0TDaFVXQn9BhFnR6OnPf+DN20GdLOMIY+Noq45JIAImjxzqu1EC4Wu cTpwbjsy0Vw/hc4U2QtlIsDcFRPPY2F6sDw3QzlExxs66u5c1vgEUCoJNTdz5H6E/9/b e6VhExnu4OZWm4GjJJ8z2ZiOk12Mjn9RMEbw5zoZqzdTERw4I2Z6GAUEMgeq0caNwtF8 3+K0i34P+puXCCKdTb5u8LQxibl6L82pZy+AWWAvwlk2/hkMqV8V6rUGMhbfq003e8X2 vh2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=mwEfxyGY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j8-v6si3483006pli.9.2018.04.12.08.51.35; Thu, 12 Apr 2018 08:52:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=mwEfxyGY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753223AbeDLPrk (ORCPT + 99 others); Thu, 12 Apr 2018 11:47:40 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:34146 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752870AbeDLPrj (ORCPT ); Thu, 12 Apr 2018 11:47:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=shy+p644cloQheMNP7a2FhDIoWo1PBlen3TlO/hIPJQ=; b=mwEfxyGYrkWs/67ubnfUAok4/ i+1Dja3R0J+vo3ZZrTolZj4zUn8TSqS3qhWK7Gj2YxlDVknCW5U3iv7XGYRmo7FJYqVLD7NjJuYen kaXPnxTPY//K7cI2z7Pzdke/X3bXe70eXUtBd27/j0JldwFQffEGQMKaW5MBpDNJ1Ziew=; Received: from n2100.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:4f86]:52101) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1f6eRf-00033Q-90; Thu, 12 Apr 2018 16:47:31 +0100 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.90_1) (envelope-from ) id 1f6eRc-00042q-OE; Thu, 12 Apr 2018 16:47:28 +0100 Date: Thu, 12 Apr 2018 16:47:27 +0100 From: Russell King - ARM Linux To: Ayan Kumar Halder Cc: liviu.dudau@arm.com, brian.starkey@arm.com, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, alexandru-cosmin.gheorghe@arm.com, nd@arm.com Subject: Re: [PATCH] tda998x: Check ref count before invoking drm_connector_cleanup in unbind Message-ID: <20180412154727.GJ16141@n2100.armlinux.org.uk> References: <1523544152-15241-1-git-send-email-ayan.halder@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1523544152-15241-1-git-send-email-ayan.halder@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 12, 2018 at 03:42:32PM +0100, Ayan Kumar Halder wrote: > In a situation when the reference count of the drm connector is greater than 1, > the unbind function should not invoke drm_connector_cleanup as this will lead > to an inconsistent state where the drm_crtc_state->connector_mask still has > a bitmask referring to the stale connector. Later, when drm driver invokes > drm_atomic_helper_shutdown() which invokes ---> drm_atomic_helper_disable_all() > ---> drm_atomic_commit() --> drm_atomic_check_only() --> > drm_atomic_helper_check() --> drm_atomic_helper_check_modeset(). This returns > an error due to enabled/connectors mismatch. > > In such a scenario, one should just return from _unbind() and let the drm driver > subsequently invoke drm_atomic_helper_shutdown. This will reset the > drm_crtc_state->connector_mask and will shutdown the crtcs. It will also decrement > the reference count of the connectors to 1. Subsequently, drm_mode_config_cleanup > will get invoked which will do the following :- If the device is still in-use after unbind() has been called, that is _very_ bad news, and probably means that the "host" driver is not calling component_unbind() at the right point. Any resources claimed in the bind() callback using devm functions will be freed, which will include (eg) the drm_encoder structure and in fact the drm_connector. So what you have here is a use-after-free bug, and your change does nothing for that. Please fix the "host" driver instead. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up