Skip to contentSkip to conversation

drivers/char/agp: Fix divide by zero warning in isoch.c

PATCH New Gautam Menghani 1 participant 1 message May 21, 2022 Agpgart driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/char/agp: Fix divide by zero warning in isoch.c

Add a check to ensure ndevs is not zero. This was found by clang scan
warning: Division by zero [core.DivideZero]

        mrq = trq / ndevs;
---
 drivers/char/agp/isoch.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/char/agp/isoch.c +3 -0
index 7ecf20a6d19c..da0d2681225b 100644
@@ -289,6 +289,9 @@ static void agp_3_5_nonisochronous_node_enable(struct agp_bridge_data *bridge,
 	u32 trq, mrq, rem;
 	unsigned int cdev = 0;
 
+	if (ndevs == 0)
+		return;
+
 	pci_read_config_dword(bridge->dev, bridge->capndx+AGPSTAT, &tstatus);
 
 	trq = (tstatus >> 24) & 0xff;
Signature · 1 line
2.25.1