Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2818374rwb; Mon, 15 Aug 2022 11:59:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5TtZ1ep2Cszzyx2hPF4CWJ853n2CT3ObflHMlxPWoCxK89jJprmUvmJNZc3tJt1nYo45Yc X-Received: by 2002:a17:907:1c27:b0:730:ad6d:9fc9 with SMTP id nc39-20020a1709071c2700b00730ad6d9fc9mr11195011ejc.583.1660589974699; Mon, 15 Aug 2022 11:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589974; cv=none; d=google.com; s=arc-20160816; b=m2XIQvX1F1VtRHtsCkfXeZ+cMcOspY+FtM7G0+X0LZW2/0hvtGZFBkkp+TjGqPqY72 7KrGa/G92TaafUZpjKQz40oPHhtVhkvcG0GHSa1/nKhDlPWNN1Cc/Q+cAsvOtBreYUTb 2lz9+JUw6wxhCmwvat0vwKTYAl5iTQpS5NriT766Cm0KAHrMjMZSwE8F4yC7k/zbgJQ6 v4rAjtE8boWMMqLmAisGlLkfwWFgojmU9K0ZD98H4N4vyum4Wv7jIlb0pGw0QjQS/Osv gqlPgJuUPr0hKGHrTLkZpiqSSQptQCStj5GHDBlu7VXFnG62qJE3cSujAt39uqp5MTIL Osug== 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=nkr37AuvEmCPAgRUUaptFAevA0ufufiKk2qmDlzDBZM=; b=H9Zs0p/UPnQhclqoHG76Yp8KG0EuBtYgx9K9WTTgDIIV4T2dDQVis+YyXoLJ9BO5XJ /HX1siLPDyF6Ypq88UhNonQom1vbHv2tWrtFXVdsCtAsyJ4BLXuHCmHkg0FP923nfSTs nWbaq1qD2d5B8htGsNxsCSjXO4mMnWo0rTJf7icOSggxnvTkv8hIPpy2m6AtDGl0yTnx T3zzR/hak+Fyr6H0p5QQhC5v0TmdVkrdbqIhQLiHvfYdWTKH+ud4RoPna0kLoxKSfhZN mAXYt3/QxbxzD9s6H7Frlw9UuGuskHNs/vASngUpPXOwu8N7JI1NoayB3/JvmuR6PfUt A1Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sR24tCoq; 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 x44-20020a50baaf000000b00440a49861dcsi7771787ede.412.2022.08.15.11.59.00; Mon, 15 Aug 2022 11:59:34 -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=sR24tCoq; 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 S243922AbiHOSyQ (ORCPT + 99 others); Mon, 15 Aug 2022 14:54:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244534AbiHOSvZ (ORCPT ); Mon, 15 Aug 2022 14:51:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC08343323; Mon, 15 Aug 2022 11:29:16 -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 2EC0F60FEE; Mon, 15 Aug 2022 18:29:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29EC1C433D6; Mon, 15 Aug 2022 18:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588155; bh=kpVBEoT6LCIL/pFUQuqn8rGR3aDGvmQPx3ShG7RBrfw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sR24tCoqaRj0AfatXAYVhfLUYOepkfJW0oxU1Xo8I9t2dNuiTdEf1NaiJwnxiWdYM p0i/vr5mWfBfKrv7UPqLAgsGfUgKWnvKP9oEY/IDH1duZIJQZI6LvOByeAPwx/yzT8 vpNszX68OSWnqOVcMP8U6x/mYIbp4ogaxLqVP1UI= 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.15 312/779] drm/rockchip: vop: Dont crash for invalid duplicate_state() Date: Mon, 15 Aug 2022 19:59:16 +0200 Message-Id: <20220815180350.631718767@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 8b4287d40379..d5b74ea06a45 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1550,6 +1550,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