Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3090136rwb; Mon, 15 Aug 2022 17:53:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR7KF/0sBRZHdW5uFs3BJXZ3Z4hMUcGEi6pin5xGMqQmtWseD//BEJEVMrFbU4nqPE8Uvpod X-Received: by 2002:a17:907:3daa:b0:730:a788:a6e4 with SMTP id he42-20020a1709073daa00b00730a788a6e4mr11809773ejc.77.1660611193963; Mon, 15 Aug 2022 17:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611193; cv=none; d=google.com; s=arc-20160816; b=J2LoCTSmSKXrA9StYBTUmNWbo2UuEUSMP3LWbzCyZ0nOeAU9s2Vcs9owzVSpRCTB2d 7qtNpbGTdqHSpxCHthmtsrhN7RarDE2qAgMHAuiV0r7ZjIf38DdFPJ+GynbOMVBHWyaU yY/6P8CNXqY65nl+r/oF3yYFI2Xy5QsCq/H8WkB3FpfegPCHi37vo0LXzH2ci/gL+zgj Uf7DKRc3CDQbzDPSQXu1VKqX3uO2nv2be2geE5GSbE5v/n1atMbLMe6GHDfeiEO0dmrG MteTASpy/YepQvF4San6n+Y5arQlyNk1XijgJeQMtM/w4hmlBDF7fSBonoHBIZu/26jv QpEg== 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=GOGlOpXzssQnDXWA//xxbVAzlu17fBmHFLMWNNnImFc=; b=uJBgMDRBIEr2pgEdAJN2l2ZsbSFu0lPcYbYIF0Z8GruIMdTkQU8tLZvOxKb2m7yupl z6dlRdkWtChmsejHyDlKzUYV9kiogIZq2fPgOFGNx6MZVp4STuJmoLjnDbPTvR7EyFSi iY5Odz6pyTOBzabOTRyGZ71jZFfeifozxY1p1ZEiTy3KyNzju5ZbZhWEf75b28rEkRw9 RVw6m1Q9kquoVDXXqAaooEcOg7Cm1JgaJ16ed4YFgeERWwnuPUHhAqrgTTfVVsBsNzAh voK39mgpMQIKmYfR9zsoENMDRt7jPCX/vd9fRZRhcjTqmfNBR7FV/7w6ofVrYDh3SxRy qBHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n9aTZsfI; 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 c11-20020a056402120b00b00443e3eed926si2113314edw.185.2022.08.15.17.52.48; Mon, 15 Aug 2022 17:53:13 -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=n9aTZsfI; 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 S1354262AbiHOXrh (ORCPT + 99 others); Mon, 15 Aug 2022 19:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354361AbiHOXl7 (ORCPT ); Mon, 15 Aug 2022 19:41:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D07E32B82; Mon, 15 Aug 2022 13:13:18 -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 BDB8360DEC; Mon, 15 Aug 2022 20:13:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3B43C433D6; Mon, 15 Aug 2022 20:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594397; bh=4JVM/F/ZIeTHbjfRZAm3nR+cu6HCNWuNJKGd5nR5J/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n9aTZsfI1bm7s3/lUnWQki0tH2Q8f7dpxpSCcpmyeoQhdGxyeoQz7IYGKpUihQXbP HxOU/bxJCOLSZ8Ac3utO8cX7Rr46DUuyL8z5tctnLEOPtY7HfDoSrZ88Ha7N/pTuQl Dwtxy+9xjkkA7XkIoTGKxrjQTYJ3NlqLqWArz2oA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Norris , Sean Paul , Douglas Anderson , Heiko Stuebner , Sasha Levin Subject: [PATCH 5.19 0432/1157] drm/rockchip: vop: Dont crash for invalid duplicate_state() Date: Mon, 15 Aug 2022 19:56:28 +0200 Message-Id: <20220815180456.939151421@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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: Brian Norris [ Upstream commit 1449110b0dade8b638d2c17ab7c5b0ff696bfccb ] It's possible for users to try to duplicate the CRTC state even when the state doesn't exist. drm_atomic_helper_crtc_duplicate_state() (and other users of __drm_atomic_helper_crtc_duplicate_state()) already guard this with a WARN_ON() instead of crashing, so let's do that here too. Fixes: 4e257d9eee23 ("drm/rockchip: get rid of rockchip_drm_crtc_mode_config") Signed-off-by: Brian Norris Reviewed-by: Sean Paul Reviewed-by: Douglas Anderson Signed-off-by: Heiko Stuebner Link: https://patchwork.freedesktop.org/patch/msgid/20220617172623.1.I62db228170b1559ada60b8d3e1637e1688424926@changeid Signed-off-by: Sasha Levin --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 74562d40f639..daf192881353 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1570,6 +1570,9 @@ static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc) { struct rockchip_crtc_state *rockchip_state; + if (WARN_ON(!crtc->state)) + return NULL; + rockchip_state = kzalloc(sizeof(*rockchip_state), GFP_KERNEL); if (!rockchip_state) return NULL; -- 2.35.1