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 B3BA0191F96; Wed, 25 Sep 2024 11:47:23 +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=1727264843; cv=none; b=lZS7vNzwWsxo92IjnKhPtwKXV3y2hUXzpREdreU0Kqri8i7LgIB24x1gwUpuM1SlsN3uwN8b+UtEPVc5aR8/qBKxAktJLFFLUkBGGElOkyv8vlO6RuSjHPTYZgkADQa8d13WjEkJe+hjNzCEuZNN/g/l0rp1jSN/hN8kkPcOTHY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727264843; c=relaxed/simple; bh=5V/RU9tEsPt7uk3hy/VSWiM8e4A6GlG5pRUtGRV74t8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WSFRuNd3I0TF9oHhGA8fj/OIr37llUfCuOdPHGEoCf0DuaBFKa2P1neKew/2gFiUEWh/cn6RZuwnEac5qOEvpv+9P7OfdnOCEXGf7GHSob+tZ/3FXlm81ldD+BiAqPznH/UiiSpA61yT1aO8A51xWIM8i9MbH59y6uDQXFnjom4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rKEYUy5+; 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="rKEYUy5+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E05FFC4CEC3; Wed, 25 Sep 2024 11:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727264843; bh=5V/RU9tEsPt7uk3hy/VSWiM8e4A6GlG5pRUtGRV74t8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rKEYUy5+0xrH5kJM52WzOPb7ZipD4299f4/swm74FwyCMYGQwozagTzEf1ptUwGeD HBWVKpRw9crcFCIXzbgaxQ8JigiCDeyXm4DW4Tpt2yhaqJLGXv6iCA8uYDiSnHnuay bMEQ8AyLJ797bGgvqzk8pKOZUXOd4hmbTg0Ywa2GKD5gfwGnVg1yLvaExNamBTsXJZ GTfLk5ai8okMOds1/oMLbD6JR0HYf/RGcDcb7GpTHYaJA4q30nTUZTTcCOGwrCd5m3 TWRJKXyXub2OGnMU2OQlMEkXWei8y/qB4APeV/zdktz+QJsNMqhQ5sdJllFy2m8s9V X9OKFt5VMG4wQ== 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 , Alex Deucher , Sasha Levin , sunpeng.li@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, mwen@igalia.com, joshua@froggi.es, marek.olsak@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.11 159/244] drm/amd/display: Add null check for 'afb' in amdgpu_dm_plane_handle_cursor_update (v2) Date: Wed, 25 Sep 2024 07:26:20 -0400 Message-ID: <20240925113641.1297102-159-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240925113641.1297102-1-sashal@kernel.org> References: <20240925113641.1297102-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.11 Content-Transfer-Encoding: 8bit From: Srinivasan Shanmugam [ Upstream commit cd9e9e0852d501f169aa3bb34e4b413d2eb48c37 ] This commit adds a null check for the 'afb' variable in the amdgpu_dm_plane_handle_cursor_update function. Previously, 'afb' was assumed to be null, but was used later in the code without a null check. This could potentially lead to a null pointer dereference. Changes since v1: - Moved the null check for 'afb' to the line where 'afb' is used. (Alex) Fixes the below: drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_plane.c:1298 amdgpu_dm_plane_handle_cursor_update() error: we previously assumed 'afb' could be null (see line 1252) Cc: Tom Chung Cc: Rodrigo Siqueira Cc: Roman Li Cc: Alex Hung Cc: Aurabindo Pillai Cc: Harry Wentland Co-developed-by: Alex Hung Signed-off-by: Alex Hung Signed-off-by: Srinivasan Shanmugam Reviewed-by: Tom Chung Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c index 5cb11cc2d0636..a573a66398984 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c @@ -1377,7 +1377,8 @@ void amdgpu_dm_plane_handle_cursor_update(struct drm_plane *plane, adev->dm.dc->caps.color.dpp.gamma_corr) attributes.attribute_flags.bits.ENABLE_CURSOR_DEGAMMA = 1; - attributes.pitch = afb->base.pitches[0] / afb->base.format->cpp[0]; + if (afb) + attributes.pitch = afb->base.pitches[0] / afb->base.format->cpp[0]; if (crtc_state->stream) { mutex_lock(&adev->dm.dc_lock); -- 2.43.0