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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux