[lvc-project] [PATCH] drm/nouveau: handle nouveau_hw_get_clock() return value
Bulatov Mark
ms.bulatov7 at gmail.com
Thu May 14 20:40:08 MSK 2026
From: Mark Bulatov <ms.bulatov7 at 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 at 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
More information about the lvc-project
mailing list