[PATCH] agp: check if ndevs is zero before enabling node

Yiyuan GUO yguoaz at gmail.com
Thu May 13 13:53:32 UTC 2021


In function agp_3_5_enable from drivers/char/agp/isoch.c, the
variable ndevs may remain zero if all AGP devices have type of
"Bridge" or "Unclassified device". Passing ndevs==0 to function
 agp_3_5_isochronous_node_enable or agp_3_5_nonisochronous_node_enable
will lead to divide by zero problems.

Signed-off-by: Yiyuan GUO <yguoaz at cse.ust.hk>
---
 drivers/char/agp/isoch.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/char/agp/isoch.c b/drivers/char/agp/isoch.c
index 7ecf20a6d..4c21bb057 100644
--- a/drivers/char/agp/isoch.c
+++ b/drivers/char/agp/isoch.c
@@ -433,6 +433,11 @@ int agp_3_5_enable(struct agp_bridge_data *bridge)
 		}
 	}		
 
+	if (!ndevs) {
+		ret = -ENODEV;
+		goto free_and_exit;
+	}
+
 	/*
 	 * Call functions to divide target resources amongst the AGP 3.0
 	 * masters.  This process is dramatically different depending on
-- 
2.25.1



More information about the dri-devel mailing list