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 30835214227; Thu, 12 Dec 2024 16:53:01 +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=1734022381; cv=none; b=AOPMQDUlK+vnaLAVJWuYmIOHRAwO9K9ZldeBuiG7Rec0R9qhPjmZvIQfjwZ945VBR5IqhILPbxfVzThWUpWBZ5WfsC0lv3RHhJ4FXBrkreyfZWP3Ylo4hSXGrPFpnvjISm3IRgwy8uK6yBuvNDqkuH2wKI7yAfLxNkLwCPFNhyg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734022381; c=relaxed/simple; bh=7NBp9oFchpyxiMO3BB1Y9jIF1GLbiTsSxSpmsw3BOGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EdSV2KQL8xmMnodGjY1NrikCWZRpjP6GPn1tMPvFBLibRhynnQk3eXgVMEYq8C7QO5/jii/0V0S48d+SDbcU81M3LXTmLwCQVyGl2BqvyYUJCZcpWNemJTbwiA1y6xWNn3hPbRvjZukb3Zqp+U2Pw/zgF8SHIevFvAJ64jQoS2A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GjcJbKib; 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="GjcJbKib" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EB67C4CECE; Thu, 12 Dec 2024 16:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734022381; bh=7NBp9oFchpyxiMO3BB1Y9jIF1GLbiTsSxSpmsw3BOGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GjcJbKibjQHv8wXtM43u3kjy15JaU49jAhm1aQh5nOktXDz3TRI1j07Nn6sPkSEPW PnjhvQbYWQMVqWgK5n+Rpp9hIyzqCnRU77Ltw1yqbiTG+9wV0d4/dd3Rji67e9BNtc 8+yBte9kaGNgdCS8OUl+Gg1QzlGvpz+uI1v8RvaU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zichen Xie , Abhinav Kumar , Dmitry Baryshkov , Sasha Levin Subject: [PATCH 5.15 185/565] drm/msm/dpu: cast crtc_clk calculation to u64 in _dpu_core_perf_calc_clk() Date: Thu, 12 Dec 2024 15:56:20 +0100 Message-ID: <20241212144318.790194844@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144311.432886635@linuxfoundation.org> References: <20241212144311.432886635@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zichen Xie [ Upstream commit 20c7b42d9dbd048019bfe0af39229e3014007a98 ] There may be a potential integer overflow issue in _dpu_core_perf_calc_clk(). crtc_clk is defined as u64, while mode->vtotal, mode->hdisplay, and drm_mode_vrefresh(mode) are defined as a smaller data type. The result of the calculation will be limited to "int" in this case without correct casting. In screen with high resolution and high refresh rate, integer overflow may happen. So, we recommend adding an extra cast to prevent potential integer overflow. Fixes: c33b7c0389e1 ("drm/msm/dpu: add support for clk and bw scaling for display") Signed-off-by: Zichen Xie Reviewed-by: Abhinav Kumar Patchwork: https://patchwork.freedesktop.org/patch/622206/ Link: https://lore.kernel.org/r/20241029194209.23684-1-zichenxie0106@gmail.com Signed-off-by: Dmitry Baryshkov Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c index 60fe06018581c..32dc298eb593e 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c @@ -80,7 +80,7 @@ static u64 _dpu_core_perf_calc_clk(struct dpu_kms *kms, mode = &state->adjusted_mode; - crtc_clk = mode->vtotal * mode->hdisplay * drm_mode_vrefresh(mode); + crtc_clk = (u64)mode->vtotal * mode->hdisplay * drm_mode_vrefresh(mode); drm_atomic_crtc_for_each_plane(plane, crtc) { pstate = to_dpu_plane_state(plane->state); -- 2.43.0