From patchwork Fri Oct 28 09:52:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 13023326 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03D27ECAAA1 for ; Fri, 28 Oct 2022 09:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yzLQ9da/Sgzt4QrS4tfi/ZskOUUkPQC1+o9nqIkTfdI=; b=fcN7MDBaW9acDa U+oHchGQ0WqDxWFcqWg5EgkE9oinOznjEsoHXxfxfNfehDN0BvSZT+BJgupOo2pZ4u30phjyMSqw0 roOAg17MOlN2flrH/jZwx/Wfps/prfYzacIJZ3gaPwvuBkmZM2990QwpZgEUpGKSS/Pfvb6s0bG8H uBZHAK2mzgwhE7wg+GyyLPp7Uj8R0EU5qPcY8Dd+ibbMhGfdLPAfUYg7opcCMAoIl1dRt1qeLED9s M8oKYwVwcjgGVbAUcCf0+XuqKexLRekDAUr0c5QYqu7Ymr7qloLqdu2MsBEfirw9AHvp2lYgirLe+ KYm1c/RP7hmZeIbRm3iA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooM53-00GSb3-JR; Fri, 28 Oct 2022 09:55:13 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooM2S-00GRSN-Rq for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 09:52:34 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ooM27-0005YW-0C; Fri, 28 Oct 2022 11:52:11 +0200 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1ooM24-000s2M-Je; Fri, 28 Oct 2022 11:52:07 +0200 Received: from mtr by dude05.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1ooM22-008xq6-NC; Fri, 28 Oct 2022 11:52:06 +0200 From: Michael Tretter To: dri-devel@lists.freedesktop.org Cc: linux-rockchip@lists.infradead.org, Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , kernel@pengutronix.de, Michael Riesch , linux-arm-kernel@lists.infradead.org, Chris Morgan , Sascha Hauer Subject: [PATCH 1/2] drm/rockchip: vop2: fix null pointer in plane_atomic_disable Date: Fri, 28 Oct 2022 11:52:05 +0200 Message-Id: <20221028095206.2136601-2-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221028095206.2136601-1-m.tretter@pengutronix.de> References: <20221028095206.2136601-1-m.tretter@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_025232_934317_012E70B5 X-CRM114-Status: GOOD ( 13.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If the vop2_plane_atomic_disable function is called with NULL as a state, accessing the old_pstate runs into a null pointer exception. However, the drm_atomic_helper_disable_planes_on_crtc function calls the atomic_disable callback with state NULL. Allow to disable a plane without passing a plane state by checking the old_pstate only if a state is passed. Signed-off-by: Michael Tretter --- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index aac20be5ac08..26f8a8489ded 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -996,13 +996,15 @@ static int vop2_plane_atomic_check(struct drm_plane *plane, static void vop2_plane_atomic_disable(struct drm_plane *plane, struct drm_atomic_state *state) { - struct drm_plane_state *old_pstate = drm_atomic_get_old_plane_state(state, plane); + struct drm_plane_state *old_pstate = NULL; struct vop2_win *win = to_vop2_win(plane); struct vop2 *vop2 = win->vop2; drm_dbg(vop2->drm, "%s disable\n", win->data->name); - if (!old_pstate->crtc) + if (state) + old_pstate = drm_atomic_get_old_plane_state(state, plane); + if (old_pstate && !old_pstate->crtc) return; vop2_win_disable(win);