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 0701821C190; Tue, 8 Jul 2025 16:59:52 +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=1751993993; cv=none; b=PiNYyk2mbgeftTjk1NzS9INCdUyMYU71arWpgU9ggwSBUoZfTrPI66DIy7pwG39bIdRf3YlSRATKYfmCTYv3S+13uvI33dDtzTHBFIri1o4A3sRF8MpH/9RVhP51YSwy109H1FCrna3Q5dytaCQUm7wPk34HfUWj7gkjSjDuyTw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751993993; c=relaxed/simple; bh=5DED0EOSC0IR4xEeS/ex8H+jBrBEt69QUKLEAigCwLk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E090MSkQ7e4oN6YS3s5Q22xkw+yFZtLJKEsx+rL9mwy6ySjhAgLtpYmjc/J3okQveFoRVEr49yvoQc3WZob+zDibcoO0EJiCs21+7tTRIK/m+Xxo0SWj6qrV9sLlbAI6QkoGNH8VYtSyr3D9is+z55eDIRIt2XS0envYch2Zw0M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=m8taP9yE; 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="m8taP9yE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 318B1C4CEED; Tue, 8 Jul 2025 16:59:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1751993992; bh=5DED0EOSC0IR4xEeS/ex8H+jBrBEt69QUKLEAigCwLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m8taP9yEL1GAFICyrlCczhimUVpbYAKz/j7itbx0PpIQkalfbcK/Kwzp3MICd0uxG tfwbQfUJsiVyQuWTcB0E2oNyQ9L9zHc1hcom9ICFO8hQyJDWv+lP2Dp7oe3lsG9KLo tuLAf/BCdOtnBFbz9pi5GOsmsea5xQX04plrE5Zw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wentao Liang , Alex Hung , Alex Deucher Subject: [PATCH 5.15 088/160] drm/amd/display: Add null pointer check for get_first_active_display() Date: Tue, 8 Jul 2025 18:22:05 +0200 Message-ID: <20250708162233.954100797@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250708162231.503362020@linuxfoundation.org> References: <20250708162231.503362020@linuxfoundation.org> User-Agent: quilt/0.68 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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wentao Liang commit c3e9826a22027a21d998d3e64882fa377b613006 upstream. The function mod_hdcp_hdcp1_enable_encryption() calls the function get_first_active_display(), but does not check its return value. The return value is a null pointer if the display list is empty. This will lead to a null pointer dereference in mod_hdcp_hdcp2_enable_encryption(). Add a null pointer check for get_first_active_display() and return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND if the function return null. Fixes: 2deade5ede56 ("drm/amd/display: Remove hdcp display state with mst fix") Signed-off-by: Wentao Liang Reviewed-by: Alex Hung Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org # v5.8 Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c +++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c @@ -364,6 +364,9 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enab struct mod_hdcp_display *display = get_first_active_display(hdcp); enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS; + if (!display) + return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND; + mutex_lock(&psp->hdcp_context.mutex); hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));