drm/nouveau: handle nouveau_hw_get_clock() return value
Subsystems (3)
PATCH 1/1 drm/nouveau: handle nouveau_hw_get_clock() return value
From: Mark Bulatov <[email protected]>
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 <[email protected]>
--- drivers/gpu/drm/nouveau/dispnv04/arb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/nouveau/dispnv04/arb.c +3 -0
@@ -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;
Signature · 1 line
2.39.5