From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58224C433F5 for ; Tue, 2 Nov 2021 15:05:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 240EE60E98 for ; Tue, 2 Nov 2021 15:05:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 240EE60E98 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To: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-Owner; bh=X1l2cXilSh4+coKWUAX0CJbWAK/vRWf6kUftHpn1h24=; b=oFc8xnXX6e4qT/+gUA6co20WgO p0W22ZWQA4nDmGrn6VZqlB1IBdJOG5TIB3H8Kw9yMRfQHqr2c+G5r+q6IL7TBSKK4zL2UzZxjoeu1 g2s1U+0xBscpSqnoQ3V93f8Nf9lWVXn1iRMXep0s7xcoNOnnadqSgG+ZCcYsjm5Z9D21BvHZ2eMQk 13AYSukmMnUBlXozsjvXTClz5qPuxpC6hgRZmZ+v5pIETJzqUDMo7kmKZ3oLCoQ/Wpv9ij5uSaWau Lz2OnN4vUpL78oOLynvkBdFCB0aJvvd3A2f3d7HMdpqk5uqaNglmXDMLn7gGBZWsuyUlZu/IFu3an KTWsIRHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhvK8-0023L1-4F; Tue, 02 Nov 2021 15:03:40 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhvK3-0023I9-Kw for linux-arm-kernel@lists.infradead.org; Tue, 02 Nov 2021 15:03:37 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 4D4095C011D; Tue, 2 Nov 2021 11:03:34 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 02 Nov 2021 11:03:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=GAofqbfPUokCWaAMbYDnlRK3LBS NmSEwo1+DLnUZQPA=; b=icIDIil8mCAEUKdAFEM7bbBKJM4c3tow+C1rVnwW+ad MUznoFGp9DBv7dGPibZgqbCm0Q0tey6/FvtxvGMTRKDKo83rf9G2yKhxNdlMfmt3 ok2BETvZfc6A/FXWa6HLmILlHq/2W0Ck38KgBOdvnRtyQqqCBsCdjlPMMDrLUlN7 TPUzShVSc2FtOhQABLAW/nG6CDrBSWD+zUDV7qS7QsKhJaLjtTsOky7z599t4nBN tzOxG1hwiy8jQtszA5drBNszSvA9817qpmRN5zGc/F9WFvj7hPNm1Mja00T9Qmdx PwF2Xw5SxETNMj8EsV57HNLhF+qICNKMGAt7pjXOjkA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=GAofqb fPUokCWaAMbYDnlRK3LBSNmSEwo1+DLnUZQPA=; b=lS0scAA9GuTPiuitbEC3dS qv4c6dADfSp8kKPWNRIHuE8oZuUWdIo6GylFAh7GPQ0zXHM35MDtWC8cyw6xfjOM D5+yvuEOr4r+xowlLSaL23J92PnfZKpdj1TkHj7FM0wJXjlbpqCsykl0M3ii8rnP OwIi08sSnJid0I0s4RAGF2pueZ517h5EQD+sMcxGjVxAZQwA3pdpPya5nXluxxNo 4xxkCQ5fLaREA7RfKJkCC8eK13Qhxi5/nImYPMxSxUHyxlvmBjlf+0eBfQwX97rY jZK0kMOquZ5OVO1hIGPffYkGO1dkiRR6VSHgUkwtySG+ZoFPtemUHHwf/xBowLeQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrtddtgdeghecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpeelkeeghefhuddtleejgfeljeffheffgfeijefhgfeufefhtdevteegheeiheeg udenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 2 Nov 2021 11:03:32 -0400 (EDT) Date: Tue, 2 Nov 2021 16:03:31 +0100 From: Maxime Ripard To: He Ying Cc: wens@csie.org, airlied@linux.ie, daniel@ffwll.ch, jernej.skrabec@gmail.com, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH -V2] drm/sun4i: Grab reference of connector before return connector from sun4i_tcon_get_connector Message-ID: <20211102150331.526nn2e6oqjbf6ur@gilmour> References: <33e01d45-c9f9-0e8c-6871-868ecd198368@huawei.com> <20211102084628.149070-1-heying24@huawei.com> MIME-Version: 1.0 In-Reply-To: <20211102084628.149070-1-heying24@huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211102_080335_798346_BE98910F X-CRM114-Status: GOOD ( 20.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0303915202495905790==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============0303915202495905790== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vw4qxeyln6gwbonp" Content-Disposition: inline --vw4qxeyln6gwbonp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue, Nov 02, 2021 at 04:46:28AM -0400, He Ying wrote: > From the comments of drm_for_each_connector_iter(), we know > that "connector is only valid within the list body, if you > want to use connector after calling drm_connector_list_iter_end() > then you need to grab your own reference first using > drm_connector_get()". So fix the wrong use of connector > according to the comments and then call drm_connector_put() > after using connector finishes. >=20 > Signed-off-by: He Ying > --- >=20 > V2: > Use proper subject prefix >=20 > drivers/gpu/drm/sun4i/sun4i_tcon.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/s= un4i_tcon.c > index 9f06dec0fc61..24fa6784ee5f 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c > +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c > @@ -47,12 +47,12 @@ static struct drm_connector *sun4i_tcon_get_connector= (const struct drm_encoder * > drm_connector_list_iter_begin(encoder->dev, &iter); > drm_for_each_connector_iter(connector, &iter) > if (connector->encoder =3D=3D encoder) { > - drm_connector_list_iter_end(&iter); > - return connector; > + drm_connector_get(connector); > + break; > } > drm_connector_list_iter_end(&iter); > =20 > - return NULL; > + return connector; Connector might be uninitialized if we don't find one here > } > =20 > static int sun4i_tcon_get_pixel_depth(const struct drm_encoder *encoder) > @@ -65,6 +65,7 @@ static int sun4i_tcon_get_pixel_depth(const struct drm_= encoder *encoder) > return -EINVAL; > =20 > info =3D &connector->display_info; > + drm_connector_put(connector); > if (info->num_bus_formats !=3D 1) We're still accessing connector->display_info here, but it might have been freed already. Maxime --vw4qxeyln6gwbonp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYYFTQwAKCRDj7w1vZxhR xW5tAP4vLeRUB7hovZ/pzeMNYb3F27REbqDmaJ5hMt09+f8PEwD/cTbVT8+nLcMU bJyX2cCnGrXIgeAL3mxTmb8Efmeypg0= =d0nY -----END PGP SIGNATURE----- --vw4qxeyln6gwbonp-- --===============0303915202495905790== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============0303915202495905790==--