sdiv can be zero if read_vco() returns 0 or khz is greater than sclk*2. This value will cause a division-by-zero error in the gt215_clk_info() function. Add a check before division. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Signed-off-by: Igor Artemiev <Igor.A.Artemiev@xxxxxxx> --- drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c index b5f3969727a2..4c53442b4167 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gt215.c @@ -206,6 +206,9 @@ gt215_clk_info(struct nvkm_clk *base, int idx, u32 khz, default: sclk = read_vco(clk, idx); sdiv = min((sclk * 2) / khz, (u32)65); + if (!sdiv) + return -EINVAL; + oclk = (sclk * 2) / sdiv; diff = ((khz + 3000) - oclk); -- 2.39.2