* [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
* Re: [PATCH] agp: check if ndevs is zero before enabling node
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
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2021-05-13 14:13 UTC (permalink / raw)
To: Yiyuan GUO; +Cc: airlied, Yiyuan GUO, keescook, dri-devel
On Thu, May 13, 2021 at 09:53:32PM +0800, Yiyuan GUO wrote:
> 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".
Can that actually happen with real hardware? Given the age of AGP code,
odds are if this could have happened, it would have by now :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Re: [PATCH] agp: check if ndevs is zero before enabling node
2021-05-13 14:13 ` Greg KH
@ 2021-05-14 2:43 ` Yiyuan GUO
0 siblings, 0 replies; 3+ messages in thread
From: Yiyuan GUO @ 2021-05-14 2:43 UTC (permalink / raw)
To: gregkh; +Cc: airlied, yguoaz, yguoaz, keescook, dri-devel
From: Yiyuan GUO <yguoaz@gmail.com>
I guess it may only happen in theory, but maybe there is no harm in
adding a simple check?
Thanks.
^ permalink raw reply [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).