From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D861B1E0DBD; Wed, 6 Nov 2024 12:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730897729; cv=none; b=qRuxNdqgGjVhiVZUhOh7J3CALgQEgZyLWp8BlRNlrURxiCxrms52glcPN6KRrlj9ikdj87OALdiYaF/stg+uNSZGWH+q7E4OOC584LzqROmQ1MTAHeDSEgSpwikm8pMn/OeMraHz70mmS/uMdQRJjcou6aczqPzh9+sEwBVzWiM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730897729; c=relaxed/simple; bh=sg2QtBR24a8HeL+Xmseki2WdS+jF4vNkLMWtYeYUrEE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MnLXmkk/mCM4a3z5Qg/sDwiVAK94w6tpfaSpTFOFc3q3YJ7UZXNIICZ5fkf9O1egyKhzZx0AsmhZNnAexync4HMay7KtebNQWGhzZ28B4+1n1BtoYzej6fkU8iFUeYGBqmyYgUMIut16Jsf3yYxQ4+AgeKqUaVEaN7lUkJUVMFE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vJwHnq4e; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="vJwHnq4e" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C28C0C4CECD; Wed, 6 Nov 2024 12:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730897729; bh=sg2QtBR24a8HeL+Xmseki2WdS+jF4vNkLMWtYeYUrEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vJwHnq4eoU+HQ4OBM1Knnb89tz6ho1bi1PZTIZXSV3kIpWkjOadLbWkv0imbdrw3o dwfUe3Wl1i+txXHjzZolku+TO44nt/vQKHFOA3XAGzhKYG2AlYBY3/TEXvxJBkhkFT 7MeO3hsK2k7uItpZCNwAt0WHcRG4CBxjbJM5MFs4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tom Chung , Nicholas Kazlauskas , Bhawanpreet Lakha , Rodrigo Siqueira , Roman Li , Hersen Wu , Alex Hung , Aurabindo Pillai , Harry Wentland , Srinivasan Shanmugam , Alex Deucher , Xiangyu Chen Subject: [PATCH 6.6 150/151] drm/amd/display: Add null checks for stream and plane before dereferencing Date: Wed, 6 Nov 2024 13:05:38 +0100 Message-ID: <20241106120312.972217351@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120308.841299741@linuxfoundation.org> References: <20241106120308.841299741@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Srinivasan Shanmugam commit 15c2990e0f0108b9c3752d7072a97d45d4283aea upstream. This commit adds null checks for the 'stream' and 'plane' variables in the dcn30_apply_idle_power_optimizations function. These variables were previously assumed to be null at line 922, but they were used later in the code without checking if they were null. This could potentially lead to a null pointer dereference, which would cause a crash. The null checks ensure that 'stream' and 'plane' are not null before they are used, preventing potential crashes. Fixes the below static smatch checker: drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:938 dcn30_apply_idle_power_optimizations() error: we previously assumed 'stream' could be null (see line 922) drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:940 dcn30_apply_idle_power_optimizations() error: we previously assumed 'plane' could be null (see line 922) Cc: Tom Chung Cc: Nicholas Kazlauskas Cc: Bhawanpreet Lakha Cc: Rodrigo Siqueira Cc: Roman Li Cc: Hersen Wu Cc: Alex Hung Cc: Aurabindo Pillai Cc: Harry Wentland Signed-off-by: Srinivasan Shanmugam Reviewed-by: Aurabindo Pillai Signed-off-by: Alex Deucher [Xiangyu: Modified file path to backport this commit] Signed-off-by: Xiangyu Chen Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c @@ -735,6 +735,9 @@ bool dcn30_apply_idle_power_optimization stream = dc->current_state->streams[0]; plane = (stream ? dc->current_state->stream_status[0].plane_states[0] : NULL); + if (!stream || !plane) + return false; + if (stream && plane) { cursor_cache_enable = stream->cursor_position.enable && plane->address.grph.cursor_cache_addr.quad_part;