Re: [PATCH] drm/nouveau: handle nouveau_hw_get_clock() return value
From: Марк Булатов
Date: Wed Nov 25 2026 - 07:46:58 EST
Hi,
Gentle ping on this patch. Please let me know if any changes or further
information are needed.
Thanks,
Mark.
On Thu, 14 May 2026 at 20:41, Bulatov Mark <ms.bulatov7@xxxxxxxxx> wrote:
>
> From: Mark Bulatov <ms.bulatov7@xxxxxxxxx>
>
> 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@xxxxxxxxx>
> ---
> 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
>