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 X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CEC8C4361B for ; Tue, 8 Dec 2020 08:34:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 EFF67233EE for ; Tue, 8 Dec 2020 08:34:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFF67233EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5AC416E975; Tue, 8 Dec 2020 08:32:30 +0000 (UTC) Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C80889933 for ; Mon, 7 Dec 2020 15:57:27 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 7C39B580220; Mon, 7 Dec 2020 10:57:26 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 07 Dec 2020 10:57:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=Ed1Z0fpkyyaC6 sMQpnbl/Y4aAtwtMQyTQwjmibZEsmU=; b=gUjTIyHdVxBTGdvOw3rQCEMIGEhsi sQLP0ZM3rUfNWtv8nG/gT/ppw6Vq6hKdJZ+BXFog3EHNdfPHOZcqohiV9SBrTkZd OSAd1hxM5/t8nrJUPELBjh6RLn7tOd1R6dXINFCQ150OgRaSBzXu/Quc1nPEP3pc KL0UJGgtwngXHM3Cn2WFJ1nFFIXusY/n9qih1CXFnp2GtRAvv/uxqmRrFs5tFfwa G5Iv10qkOTfd/Lg+Lvy5LLnx/Lti/Cq20SYO+CLZ9DXvGP1E7Ln4DIVoMMTTbYX/ L/vdiuh6RbXy2lczv1Bt3jk1pWhIfWnjG2KMOu5U4sL43Axw5dOCkK6tw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=Ed1Z0fpkyyaC6sMQpnbl/Y4aAtwtMQyTQwjmibZEsmU=; b=ork0zpHw a9G+o9SHT8Fu9TAx7YgaUGzas7Bg8aVjnHxPgub4bIaagQuE/RyQbbw704pSFG2a ktVJSKL9VYQok/f43rvmyLh+jPWkyvDpnbqPyHgA0Ai93C84F9DMhrFna5eDAoVO YrPPbxHbNqH1nbes8HSRmTYy22s3ov9Im6r0tjFG8YLR22y/lnRWcT5JsUx202Ob kaMFTY3XjE8soEA+wy/eRnnBJYu/DE+QTUkIkC83pSOIxEkOL9J1XJSlDB/A9Jl3 CN7icNjfbdxDJrY4Fhu6b4USGYV0jepTtvmaLjOtZsUR/pFsKPujwIV+BwCTX93U fzywHt7KnYh4Kw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudejgedgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepvdenuc frrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 3DCD41080067; Mon, 7 Dec 2020 10:57:26 -0500 (EST) From: Maxime Ripard To: Daniel Vetter , David Airlie , Eric Anholt , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard Subject: [PATCH v5 4/9] drm/vc4: hdmi: Don't access the connector state in reset if kmalloc fails Date: Mon, 7 Dec 2020 16:57:14 +0100 Message-Id: <20201207155719.17149-5-maxime@cerno.tech> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201207155719.17149-1-maxime@cerno.tech> References: <20201207155719.17149-1-maxime@cerno.tech> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 08 Dec 2020 08:32:06 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Dave Stevenson Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_atomic_helper_connector_reset uses kmalloc which, from an API standpoint, can fail, and thus setting connector->state to NULL. However, our reset hook then calls drm_atomic_helper_connector_tv_reset that will access connector->state without checking if it's a valid pointer or not. Make sure we don't end up accessing a NULL pointer. Acked-by: Thomas Zimmermann Suggested-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index a88aa20beeb6..61039cc89d9d 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -171,7 +171,9 @@ static int vc4_hdmi_connector_get_modes(struct drm_connector *connector) static void vc4_hdmi_connector_reset(struct drm_connector *connector) { drm_atomic_helper_connector_reset(connector); - drm_atomic_helper_connector_tv_reset(connector); + + if (connector->state) + drm_atomic_helper_connector_tv_reset(connector); } static const struct drm_connector_funcs vc4_hdmi_connector_funcs = { -- 2.28.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel