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.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 BC200C4167B for ; Thu, 10 Dec 2020 14:25:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 4A14123D23 for ; Thu, 10 Dec 2020 14:25:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A14123D23 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=7dfgGRdG/N/Uycetzx1GtSrtbj3BZ9tGIxScZbxrtY8=; b=UgRWZvnq8Lg/rNJkRUuGmqzBw 2XlyFg3KSokq9IiScBiI6BykDyPZCuEcKi0c4sX9+DSS8laYD2FkrUULFp3gjLhuk4DsUp6XSzOyL Ihv8JnWm3XoAuHvEOefBnCQGDXLoYVCJmwsREEqA4ATStg4wDSGcpsDlrXk93FJGe4JTAk5NrfLcd dlUTETXhc0jnJs4+wzquwsBDMtcovKRS6jhjKdcZ+tS/Jfrj2TLgZX3hsV7q/rd52HZ1vus3URQDE 88B6BuQ4/iN1guEDthf8E9FHk3RJkU/gHneRZTNEKQcP2+BXM5wm3HCFnufWnf5zvV5QGjCchDLWY lSwpzub8w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knMrd-0003oc-H5; Thu, 10 Dec 2020 14:24:13 +0000 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1knMr4-0003dH-9t; Thu, 10 Dec 2020 14:23:40 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id D8F3B455; Thu, 10 Dec 2020 09:23:36 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 10 Dec 2020 09:23:37 -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=83kZ4pXmfvMiM WnGP2rS7tH+UOZXtIm2wa0gfyJc2hM=; b=Um7y9w5Rc+lt5tykjQvy4astu4Pg3 JSax+CzDmCrNbMROn4r0/wkuicoobXfV3uS7CXU5EhnGmvie3hopOXVQv8qOb3xi Z0u/t677neCGs3q0dOIZOh+TcPU1hTVZI0QrOnPinVjoUrcSv5iYDQltV6tdsAfs G/oVtwSXN0SZtYbQVD1JBxmc5GfIS6psqpcmKBMX/oQDwMEuj+eim7UNJx7fkpph XqkYyC289lXgT7B9lkSfXKBLkXphdrPO5DBvcWLx5Wq7QGsQ6zJ7w8FHQoJ5YQpb HXPJwdliC1gKGoVO5p5YF4lYvq5C86E4sa1VLwK5poMz4z9iKHanFgG1w== 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=83kZ4pXmfvMiMWnGP2rS7tH+UOZXtIm2wa0gfyJc2hM=; b=e1sV9EFj /b8ZxYWtR3OpsLn5eFBu5KapvDN98ONSh7idmnokFMNS5mzu1ZefAOnnzb1SH1dy J7uy0xWsBsF9G8Ok+vSxoQIbQhIHDEzrENJPgFMI4UXTeAQCjSxoAbI69yXKe08e FrGKVAKvq/+bdvXTvvHkQZbGZY69Tv8gPZ4vYvx0H0bwK6nbw6/gvn8zloRc1MlZ lsX5zMwUmASoDKPxV4aCaWFvBva+x5P5bA36wgZvdaYXZ2M33KnhFEB4PKNjOUCc 5mu33wZutdmZLduWEY1HkcEuPKyOKycu2U/0ArG3qFacnf/Qbbd2PwyTOrzmIlNN IO5U07vhl1bxRw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudektddgieefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepudenuc 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 F36B3240057; Thu, 10 Dec 2020 09:23:35 -0500 (EST) From: Maxime Ripard To: Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Daniel Vetter , David Airlie , Eric Anholt Subject: [PATCH v6 4/9] drm/vc4: hdmi: Don't access the connector state in reset if kmalloc fails Date: Thu, 10 Dec 2020 15:23:24 +0100 Message-Id: <20201210142329.10640-5-maxime@cerno.tech> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201210142329.10640-1-maxime@cerno.tech> References: <20201210142329.10640-1-maxime@cerno.tech> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201210_092338_492538_A72781A1 X-CRM114-Status: GOOD ( 12.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Dave Stevenson Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Dave Stevenson 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 856C6C4361B for ; Thu, 10 Dec 2020 14:49:21 +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 4D7102310E for ; Thu, 10 Dec 2020 14:49:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D7102310E 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 6729E6EACF; Thu, 10 Dec 2020 14:48:28 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id D226F6E8B3 for ; Thu, 10 Dec 2020 14:23:37 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id D8F3B455; Thu, 10 Dec 2020 09:23:36 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 10 Dec 2020 09:23:37 -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=83kZ4pXmfvMiM WnGP2rS7tH+UOZXtIm2wa0gfyJc2hM=; b=Um7y9w5Rc+lt5tykjQvy4astu4Pg3 JSax+CzDmCrNbMROn4r0/wkuicoobXfV3uS7CXU5EhnGmvie3hopOXVQv8qOb3xi Z0u/t677neCGs3q0dOIZOh+TcPU1hTVZI0QrOnPinVjoUrcSv5iYDQltV6tdsAfs G/oVtwSXN0SZtYbQVD1JBxmc5GfIS6psqpcmKBMX/oQDwMEuj+eim7UNJx7fkpph XqkYyC289lXgT7B9lkSfXKBLkXphdrPO5DBvcWLx5Wq7QGsQ6zJ7w8FHQoJ5YQpb HXPJwdliC1gKGoVO5p5YF4lYvq5C86E4sa1VLwK5poMz4z9iKHanFgG1w== 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=83kZ4pXmfvMiMWnGP2rS7tH+UOZXtIm2wa0gfyJc2hM=; b=e1sV9EFj /b8ZxYWtR3OpsLn5eFBu5KapvDN98ONSh7idmnokFMNS5mzu1ZefAOnnzb1SH1dy J7uy0xWsBsF9G8Ok+vSxoQIbQhIHDEzrENJPgFMI4UXTeAQCjSxoAbI69yXKe08e FrGKVAKvq/+bdvXTvvHkQZbGZY69Tv8gPZ4vYvx0H0bwK6nbw6/gvn8zloRc1MlZ lsX5zMwUmASoDKPxV4aCaWFvBva+x5P5bA36wgZvdaYXZ2M33KnhFEB4PKNjOUCc 5mu33wZutdmZLduWEY1HkcEuPKyOKycu2U/0ArG3qFacnf/Qbbd2PwyTOrzmIlNN IO5U07vhl1bxRw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudektddgieefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecukfhppeeltddrkeelrdeikedrjeeinecuvehluhhsthgvrhfuihiivgepudenuc 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 F36B3240057; Thu, 10 Dec 2020 09:23:35 -0500 (EST) From: Maxime Ripard To: Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Daniel Vetter , David Airlie , Eric Anholt Subject: [PATCH v6 4/9] drm/vc4: hdmi: Don't access the connector state in reset if kmalloc fails Date: Thu, 10 Dec 2020 15:23:24 +0100 Message-Id: <20201210142329.10640-5-maxime@cerno.tech> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201210142329.10640-1-maxime@cerno.tech> References: <20201210142329.10640-1-maxime@cerno.tech> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 10 Dec 2020 14:48:10 +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: dri-devel@lists.freedesktop.org, bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.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 Reviewed-by: Dave Stevenson 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