dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] agp: check if ndevs is zero before enabling node
@ 2021-05-13 13:53 Yiyuan GUO
  2021-05-13 14:13 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Yiyuan GUO @ 2021-05-13 13:53 UTC (permalink / raw)
  To: airlied; +Cc: Yiyuan GUO, gregkh, yguoaz, keescook, dri-devel

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-14  7:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13 13:53 [PATCH] agp: check if ndevs is zero before enabling node Yiyuan GUO
2021-05-13 14:13 ` Greg KH
2021-05-14  2:43   ` Yiyuan GUO

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).