Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp3729435rwi; Wed, 2 Nov 2022 02:22:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5b3CX4hMnYkfAe1de8AFpG/TsHzSQznPVJ59HACq8DNuHRXoaRSRP1NH4j9OE0swp0WVr0 X-Received: by 2002:a05:6402:2793:b0:462:39d7:3bbc with SMTP id b19-20020a056402279300b0046239d73bbcmr23509343ede.47.1667380978614; Wed, 02 Nov 2022 02:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667380978; cv=none; d=google.com; s=arc-20160816; b=qyzJdRiAFcZH7t8NdkYuKZ+eVuQHV4pg0n6jELELwA6S3Dsl3s5Q+bYjqnUIRPNIfR QL5/ZC/yzTh3je6Zs/11anIDkvZDPFlA0vCgoS4dkUyBMIVd4PUipiQ4IUEXqL/O+53g 0bv1mM3jlKUbwf4vpaOxYmw7vFT9zIku18wwA50SEG1hzhZrtqqRMlFjAouDZ9FICV3S XoOIddV2QsHN1wfygHzKIcIHGgT0KJ368QUJsjfxDE+gEZw14k+Px6jTSWyCt7jTbWK6 clq7Ltx7BRHtY9up5BnyWvsgZhvw5ncHkYqYd/pEDRg6MJNWdJWy/MXSFp58tGZ5Apes mQrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=48VenoOPolgMO139tezfkS2fXuf8/WKG9H0qot9z5VY=; b=RIzkH4nbfRr47o+eZTF0Uiw0ru3gYT+2Znu1Hw9HnW6AkI9S1Xd35v5s6mbr8huREA SHoTa3fi4jmAX9usJiyAYKQ6X9d1SOnSKgr6F8T/1pGy9xqk2D3KWM9hLxwNEnADEtb0 lliM09WuY0x9jsqoNyVSt2EY4wNkxoIkJLRLkhlDCeh+kqonJiiUtynnllYhQIZvFSyo EhyAvP6RnivRFaC7j73AfD2P/gtceH41stwCx0cAR8WP9VrqTiyvD7KD7mbrkDzCL/ZP HpkZhKXfDUxTusHJhxJ2cY8o6T1bdflIuQ9p69qmKu1oYJC/7mDSX77cJyl3sRzJnsjT dKvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=Jmz2uxkX; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=BfKnTLpp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd41-20020a1709076e2900b007addc76341csi11726853ejc.25.2022.11.02.02.22.32; Wed, 02 Nov 2022 02:22:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=Jmz2uxkX; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=BfKnTLpp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231293AbiKBJDR (ORCPT + 97 others); Wed, 2 Nov 2022 05:03:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbiKBJCS (ORCPT ); Wed, 2 Nov 2022 05:02:18 -0400 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19B3E27FF6 for ; Wed, 2 Nov 2022 02:02:00 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 2303F3200909; Wed, 2 Nov 2022 05:01:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 02 Nov 2022 05:01:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1667379716; x=1667466116; bh=48VenoOPol gMO139tezfkS2fXuf8/WKG9H0qot9z5VY=; b=Jmz2uxkX8LspX9gsCjI+UgokQU B4jdfxcVaO8tilJN8wiOlE/nMhwNR/dyxDy+lhWtrOrfC7bvdOano80yspJRTr22 a/zSeQ3KFu6bN7GEcJ7QT/0y0GpybjjKbzO0rl+SIAiWTsaVI20WGrL6qwGRvPHJ PJtLZfl/Msa4LGh139y/8hcIXt8rZZQ/nMDLy1rEHueAIpjMDv9xyf8ElBAQZBhE otba3eOEuDnhKBfL8WDAdKkQAjHqMg47ZsMQ4VA4zGxUjKIUXzmggYna/r/syaDu k6TjRkbTsDibFbybjH8hHctJd/+vOL2zNb3IUARB4qNEvZqAJfjmptwXPlvA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1667379716; x=1667466116; bh=48VenoOPolgMO139tezfkS2fXuf8 /WKG9H0qot9z5VY=; b=BfKnTLpp3/fwmxWOpdJfLd3PgUMOFkY7QswAA8qUZC8H aX8Y7x5UdnTvj2geJ4KWu5kex/cZDf37f7cOTH7pzqSjekc9wgTlnbG8bM/V7DFZ nQn0QiFL9pp0kkaU4bSLl1Tlv/SdgEpPLOQRKC9C3Ly4CLSHx883VbyIaFR5A14p /0EoEZ5CnDTeVp8leE3u8WwTKYhh6YCe+it7OzdbwHUp2R2xurJ8TbnnTjyARAHN 3C4QUac1oVBxjyviiBda+KNWB2JigGFCR7F5Cpy7hY9n1FoWz25Ur5C28OfKtnPe qelrM368KKv1Ygat5o92ZVxiPrfdUqCsvNuKmt4J3Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrudeigdduvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtudenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeejveefheefkeeiffegveelveetgffffeektdefuefhtedtgeejhefggedu ffffudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 2 Nov 2022 05:01:55 -0400 (EDT) Date: Wed, 2 Nov 2022 10:01:53 +0100 From: Maxime Ripard To: =?utf-8?B?Sm9zw6kgRXhww7NzaXRv?= Cc: emma@anholt.net, airlied@gmail.com, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/vc4: hdmi: Fix pointer dereference before check Message-ID: <20221102090153.tujblkvd3jlhdtxr@houat> References: <20221029093413.546103-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2piuzv5jj7zmiqf3" Content-Disposition: inline In-Reply-To: <20221029093413.546103-1-jose.exposito89@gmail.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --2piuzv5jj7zmiqf3 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Sat, Oct 29, 2022 at 11:34:13AM +0200, Jos=E9 Exp=F3sito wrote: > Commit 6bed2ea3cb38 ("drm/vc4: hdmi: Reset link on hotplug") introduced > the vc4_hdmi_reset_link() function. This function dereferences the > "connector" pointer before checking whether it is NULL or not. >=20 > Rework variable assignment to avoid this issue. >=20 > Fixes: 6bed2ea3cb38 ("drm/vc4: hdmi: Reset link on hotplug") > Signed-off-by: Jos=E9 Exp=F3sito > --- > drivers/gpu/drm/vc4/vc4_hdmi.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdm= i.c > index 4a73fafca51b..07d058b6afb7 100644 > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c > @@ -319,9 +319,9 @@ static int reset_pipe(struct drm_crtc *crtc, > static int vc4_hdmi_reset_link(struct drm_connector *connector, > struct drm_modeset_acquire_ctx *ctx) > { > - struct drm_device *drm =3D connector->dev; > - struct vc4_hdmi *vc4_hdmi =3D connector_to_vc4_hdmi(connector); > - struct drm_encoder *encoder =3D &vc4_hdmi->encoder.base; > + struct drm_device *drm; > + struct vc4_hdmi *vc4_hdmi; > + struct drm_encoder *encoder; > struct drm_connector_state *conn_state; > struct drm_crtc_state *crtc_state; > struct drm_crtc *crtc; > @@ -332,6 +332,10 @@ static int vc4_hdmi_reset_link(struct drm_connector = *connector, > if (!connector) > return 0; > =20 > + drm =3D connector->dev; > + vc4_hdmi =3D connector_to_vc4_hdmi(connector); > + encoder =3D &vc4_hdmi->encoder.base; > + I don't think that's right. Connector shouldn't be NULL to begin with, how did you notice this? Maxime --2piuzv5jj7zmiqf3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCY2IyAQAKCRDj7w1vZxhR xclpAQDwusHvGhXtWLqUZjV4oaBclOlKnVClFcnplMVjERHSHAD+MZOvuaDd+PPh thSlYBgAKiDk4ReeyGf+XLKy4NCa0QE= =T/lW -----END PGP SIGNATURE----- --2piuzv5jj7zmiqf3--