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 C09ED18C02D; Wed, 25 Sep 2024 12:04:39 +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=1727265879; cv=none; b=fNFzzYh+XYQeZp5IfDLKQx0VtbhHwfuyn7V3IjcLBUWMalGZ7/XePnEE5Z09S/RmHXIdLZDE7ccsbwyhD45D8kRMU4m85YR9H32qdt8xaou5utEl/bJEw+khL81JGeDZzEHVbcwOBAxuH9wA30n5jFLTM5qZKbhrvoMRFfmzTZI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727265879; c=relaxed/simple; bh=KD3lBFYxOiJ8wfJr84+zY4GhCfJGMG5DC0FTapxsVBQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T7y3DLsRV14xP0U6nEodNQIiYa2NVI+4qvjuGAJplWlCMNWqgHo/z1b88wrxWsRAX02N4m7Tibkcn24he8WLJIC15UoGUHpBFWov03oLN8r9EZvl1yFeD5D6PE/v5U6pLoAuNQwa00oBOBF+myz+iii0B2ZvTigeLk+csVRziG8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NVlmjBqc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NVlmjBqc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D29ECC4CEC3; Wed, 25 Sep 2024 12:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727265879; bh=KD3lBFYxOiJ8wfJr84+zY4GhCfJGMG5DC0FTapxsVBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NVlmjBqcdbaqwYBaoYFVpijpfZPX0cVK4ih4uu1EfjiF8jpckqDmthVG7ThkWDsVC 39LzYDYk0UzA8Zx0FhpdJUIknp4IiIEXTqtXpr6+e9shwP1+lOtR/XOUedLCbcC4DA PCmii0oNOlDV951jm2ywFS4LqGuNU+HsVHh+vy7y/+YKwzwRnnHJSUMvdrzEsMLXA3 KB1Jx+ocNGIj0rzTBP6/eKVJBqSlP6f1x+3nTPO8cn/DUFU5jDFfyPaj5WTWQuhezV Z3kdnDgubJviibcMZuuCpxtyCeG3XP6mojZJstYHQ2+LtqPA6txZpCmnHw60OIS+cM CYdHjyjxieu6g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Srinivasan Shanmugam , Tom Chung , Rodrigo Siqueira , Roman Li , Alex Hung , Aurabindo Pillai , Harry Wentland , Hamza Mahfooz , Alex Deucher , Sasha Levin , sunpeng.li@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, alvin.lee2@amd.com, wenjing.liu@amd.com, chaitanya.dhere@amd.com, dillon.varone@amd.com, joshua.aberback@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.10 118/197] drm/amd/display: Add null check for head_pipe in dcn32_acquire_idle_pipe_for_head_pipe_in_layer Date: Wed, 25 Sep 2024 07:52:17 -0400 Message-ID: <20240925115823.1303019-118-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240925115823.1303019-1-sashal@kernel.org> References: <20240925115823.1303019-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.10.11 Content-Transfer-Encoding: 8bit From: Srinivasan Shanmugam [ Upstream commit ac2140449184a26eac99585b7f69814bd3ba8f2d ] This commit addresses a potential null pointer dereference issue in the `dcn32_acquire_idle_pipe_for_head_pipe_in_layer` function. The issue could occur when `head_pipe` is null. The fix adds a check to ensure `head_pipe` is not null before asserting it. If `head_pipe` is null, the function returns NULL to prevent a potential null pointer dereference. Reported by smatch: drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn32/dcn32_resource.c:2690 dcn32_acquire_idle_pipe_for_head_pipe_in_layer() error: we previously assumed 'head_pipe' could be null (see line 2681) Cc: Tom Chung Cc: Rodrigo Siqueira Cc: Roman Li Cc: Alex Hung Cc: Aurabindo Pillai Cc: Harry Wentland Cc: Hamza Mahfooz Signed-off-by: Srinivasan Shanmugam Reviewed-by: Tom Chung Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c index d84c8e0e5c2f0..9209bcad699a8 100644 --- a/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +++ b/drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c @@ -2664,8 +2664,10 @@ static struct pipe_ctx *dcn32_acquire_idle_pipe_for_head_pipe_in_layer( struct resource_context *old_ctx = &stream->ctx->dc->current_state->res_ctx; int head_index; - if (!head_pipe) + if (!head_pipe) { ASSERT(0); + return NULL; + } /* * Modified from dcn20_acquire_idle_pipe_for_layer -- 2.43.0