public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: handle nouveau_hw_get_clock() return value
@ 2026-05-14 17:40 Bulatov Mark
  2026-05-16  0:30 ` Claude review: " Claude Code Review Bot
  2026-05-16  0:30 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Bulatov Mark @ 2026-05-14 17:40 UTC (permalink / raw)
  To: Lyude Paul
  Cc: Mark Bulatov, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Ben Skeggs,
	Dave Airlie, dri-devel, nouveau, linux-kernel, lvc-project

From: Mark Bulatov <ms.bulatov7@gmail.com>

In the nv04_update_arb() function, MClk and NVClk are passed to
nv04_calc_arb() or nv10_calc_arb(), where they are used as divisors.
MClk and NVClk are calculated using nouveau_hw_get_clock(), which, via
nouveau_hw_pllvals_to_clk(), can return 0, resulting in division by 0.

The result of nouveau_hw_get_pllvals() in the nouveau_hw_get_clock()
function can also return -ENOENT, which is not checked anywhere.

Fix all this by adding a check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 6ee738610f41 ("drm/nouveau: Add DRM driver for NVIDIA GPUs")
Signed-off-by: Mark Bulatov <ms.bulatov7@gmail.com>
---
 drivers/gpu/drm/nouveau/dispnv04/arb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/arb.c b/drivers/gpu/drm/nouveau/dispnv04/arb.c
index 1d3542d6006b..2f59b8739fc1 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/arb.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/arb.c
@@ -202,6 +202,9 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp,
 	uint32_t cfg1 = nvif_rd32(device, NV04_PFB_CFG1);
 	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
+	if (MClk <= 0 || NVClk <= 0)
+		return;
+
 	sim_data.pclk_khz = VClk;
 	sim_data.mclk_khz = MClk;
 	sim_data.nvclk_khz = NVClk;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-16  0:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-14 17:40 [PATCH] drm/nouveau: handle nouveau_hw_get_clock() return value Bulatov Mark
2026-05-16  0:30 ` Claude review: " Claude Code Review Bot
2026-05-16  0:30 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox