From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B551448D18; Fri, 7 Aug 2026 14:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114753; cv=none; b=lbBsJWrWbUkSt4dWbngYWUUkMcIKohrZjgVxo79quFHB3Y6S8BTxzQDrfQvufP7v912PjcwPZZyBvK6X5q+ZKVDKtIp8Hse5aDrDJ/l4JPq5sS7m5oKQJn7mNGjxd0ftny2AXmLOuHHn9USMI3gQ/+v6gRDas/M1hEVijMOrFGY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114753; c=relaxed/simple; bh=EHoktM07REgU6JIUHaOasvQgI2EkyvI+jAYz8fJmntA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oe3yBbC1E84PCpUjcvDD55sIJ0Kd0bfuH20ykA/cXg6LCdz11HzDy8Myg92kfrIaUJUPrJtvQxOaRXz5xr7NqfPD/w5Rmy5byb1FzrqZ4z/jfLN5u2z1rsOC3aKO83/E6GoLGx/3dQXPAQswNPUrp0IFwMIg+qqexxcj+N7AOf0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jvC4pCss; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jvC4pCss" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 016F01F000E9; Fri, 7 Aug 2026 14:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786114752; bh=nJHhoAW0OvE0GgYXGSJT3sbgx5CGD2itTqIUdQJPN2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jvC4pCssShn2CPXoNnPc+z8HAdQAy2/53NfK1WNh31MlhxSEZUH3obS0X/MaTWC2F eAfm/E4EzcFZrfmBH1Qv/yhUydu4eJd+SLipvMr47RG2zqiOR+i7++avVvdtOX9Mwh bVQZk2ZXlONpJVRHHdLzPDLlDEMb79zRGk3xKtWY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ruoyu Wang , CK Hu , Chun-Kuang Hu , Sasha Levin Subject: [PATCH 6.18 035/396] drm/mediatek: Check CRTC state before freeing Date: Fri, 7 Aug 2026 16:33:15 +0200 Message-ID: <20260807143425.030768241@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143424.272339768@linuxfoundation.org> References: <20260807143424.272339768@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ruoyu Wang [ Upstream commit 233a4d3a39fc1585f5e271b2adab43c6af025ae0 ] mtk_crtc_reset() destroys the current CRTC state only when crtc->state is non-NULL, but it always converts crtc->state to struct mtk_crtc_state and passes the result to kfree(). When reset is called without an existing state, container_of(NULL, ...) does not produce NULL. Keep the mtk state free in the same crtc->state guard as the helper state destruction. This issue was found by a static analysis checker and confirmed by manual source review. Fixes: 2d267b81898e ("drm/mtk: Use __drm_atomic_helper_crtc_reset") Signed-off-by: Ruoyu Wang Reviewed-by: CK Hu Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20260707150528.2270739-1-ruoyuw560@gmail.com/ Signed-off-by: Chun-Kuang Hu Signed-off-by: Sasha Levin --- drivers/gpu/drm/mediatek/mtk_crtc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c b/drivers/gpu/drm/mediatek/mtk_crtc.c index c4c6d0249df56..aa8e6f6ddcd32 100644 --- a/drivers/gpu/drm/mediatek/mtk_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_crtc.c @@ -153,10 +153,10 @@ static void mtk_crtc_reset(struct drm_crtc *crtc) { struct mtk_crtc_state *state; - if (crtc->state) + if (crtc->state) { __drm_atomic_helper_crtc_destroy_state(crtc->state); - - kfree(to_mtk_crtc_state(crtc->state)); + kfree(to_mtk_crtc_state(crtc->state)); + } crtc->state = NULL; state = kzalloc(sizeof(*state), GFP_KERNEL); -- 2.53.0