Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1856848rwb; Fri, 19 Aug 2022 10:31:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR75RwFVwQ6nQ5VWMKsivxx6n1TX7R8yiRieQHanBsek3k+3VKD7R5qSbb9oGsW+ogqXxcnP X-Received: by 2002:a05:6a00:850:b0:52e:d1c1:df48 with SMTP id q16-20020a056a00085000b0052ed1c1df48mr8748205pfk.75.1660930291750; Fri, 19 Aug 2022 10:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930291; cv=none; d=google.com; s=arc-20160816; b=UFtGNGcoHi+La2NtIOvLXyUOYycEKX3dIuIX8bCcVLg7GsBUV035HP1TtYfrMRR9VU CPLgJfJ7vBTee8AqK0FCaJKjP8mZAOZQbBqPn9T15rgqlF7ypeATmAJRZ/1ywIeQ6uq2 MMkoSMTvEOvDbhlVpyfc09xSlRtPasHPTljEGXP5mZEqFlkpe46/a+5jLPXATHJwmfKK 9lWLLrWRh2jPHIIwGj1YA0k+as7XSYnAwidusnrJrvCJCjH65R2IKnS9LnV4cXwxVP3m +P4xkFH2AiXA8XWL1zOSFyKd41veu8+m6X+mCd1Hr3BdslUu45sxr4ci6NbEW2+x87by BwCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zb6uu9orRwa6dIlTeK/hd0POYtAUCrYg5SBfCH9ixpY=; b=aIz1pG+/gpBhViEr29zy4HDOg9TGBYcB6DLiUU7bVIwKO2DCnjcKolXedwl+/zwj6X 5gKyFaBQTVJdt04nKsHZWgYY+edltu8NS/eZobCP7smLy+qT3hOmZLcZMLiog8GGntxi NjLLcJgNBDbFO2cwyCHAXGHktc7tDkhCMGCxlX9ljZxKVqZBO1XxvXe48QNCY27/w5mK q5GV+YLL+qP3+HnGkq0JyR4hFAI++01ukvoAM9OtBNDYXdOdqOrzpOD+Se2I3ssHC88p FnpKOtleooFS07Iyr8b3Y15EcQJz2IpdmiRBXCZoI2OWEQ38Ie04dr7PlZfYmDj2UlHu Hz6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1gTGlnhu; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a170902d39100b0016e3d42897fsi801845pld.277.2022.08.19.10.31.19; Fri, 19 Aug 2022 10:31:31 -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=@linuxfoundation.org header.s=korg header.b=1gTGlnhu; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351686AbiHSQJq (ORCPT + 99 others); Fri, 19 Aug 2022 12:09:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351758AbiHSQG3 (ORCPT ); Fri, 19 Aug 2022 12:06:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB23D107F05; Fri, 19 Aug 2022 08:55:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 78D87616B3; Fri, 19 Aug 2022 15:55:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C805C433C1; Fri, 19 Aug 2022 15:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924532; bh=UKa314WESJCjsyExFx48p4VTNyM/6qFWQEI7i2N5gms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1gTGlnhuyttwDeqeGfFxGwbWpk4kI0o/xxcBMUyUsa2t68cP7RR0hRHRqk88aVIKk oa4vW0/Ys2WvOTavqz+nTGidVHokLV1jFDgoB2I0qwbazSwvmtrMZ3xjSlOPk/tQGt StL5M0ofSQLwtw3w3MuBADdekffKETtmpFWvG2T8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Zimmermann , Dave Stevenson , Maxime Ripard , Sasha Levin Subject: [PATCH 5.10 201/545] drm/vc4: hdmi: Dont access the connector state in reset if kmalloc fails Date: Fri, 19 Aug 2022 17:39:31 +0200 Message-Id: <20220819153838.387286468@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Maxime Ripard [ Upstream commit e55a07751146ef8ebc2c561564437b78f46405d3 ] 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 Link: https://patchwork.freedesktop.org/patch/msgid/20201215154243.540115-5-maxime@cerno.tech Signed-off-by: Sasha Levin --- 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 9a90f22df3d2..978afe706ee2 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -209,7 +209,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.35.1