|
@@ -1095,8 +1095,8 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
|
|
|
- /* AK: could wrap */
|
|
|
- if ((pg_start + mem->page_count) > num_entries)
|
|
|
+ if (((pg_start + mem->page_count) > num_entries) ||
|
|
|
+ ((pg_start + mem->page_count) < pg_start))
|
|
|
return -EINVAL;
|
|
|
|
|
|
j = pg_start;
|
|
@@ -1130,7 +1130,7 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
|
|
|
{
|
|
|
size_t i;
|
|
|
struct agp_bridge_data *bridge;
|
|
|
- int mask_type;
|
|
|
+ int mask_type, num_entries;
|
|
|
|
|
|
bridge = mem->bridge;
|
|
|
if (!bridge)
|
|
@@ -1142,6 +1142,11 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
|
|
|
if (type != mem->type)
|
|
|
return -EINVAL;
|
|
|
|
|
|
+ num_entries = agp_num_entries();
|
|
|
+ if (((pg_start + mem->page_count) > num_entries) ||
|
|
|
+ ((pg_start + mem->page_count) < pg_start))
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
mask_type = bridge->driver->agp_type_to_mask_type(bridge, type);
|
|
|
if (mask_type != 0) {
|
|
|
/* The generic routines know nothing of memory types */
|