Skip to contentSkip to conversation

agp: Re-order a condition to please static checkers

PATCH New Dan Carpenter 1 participant 1 message May 29, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 agp: Re-order a condition to please static checkers

It's nicer to check for integer overflow first and then check for if the "page_count" is within bounds, otherwise static checkers complain.

---
 drivers/char/agp/generic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/agp/generic.c +2 -2
index 658664a5a5aa..89901e5710bf 100644
@@ -227,8 +227,8 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge,
 		return NULL;
 
 	cur_memory = atomic_read(&bridge->current_memory_agp);
-	if ((cur_memory + page_count > bridge->max_memory_agp) ||
-	    (cur_memory + page_count < page_count))
+	if ((cur_memory + page_count < page_count) ||
+	    (cur_memory + page_count > bridge->max_memory_agp))
 		return NULL;
 
 	if (type >= AGP_USER_TYPES) {
Signature · 1 line
2.20.1