1
0
Fork 0

[AGPGART] Prevent (unlikely) memory leak in amd_create_gatt_pages()

If we fail an alloc, unwind the previous allocs that succeeded.

Spotted-by: Alan Grimes <agrimes@speakeasy.net>
Signed-off-by: Dave Jones <davej@redhat.com>
hifive-unleashed-5.1
Dave Jones 2007-01-28 17:39:19 -05:00
parent 4b95320fc4
commit c30efbaeaa
1 changed files with 5 additions and 0 deletions

View File

@ -101,6 +101,11 @@ static int amd_create_gatt_pages(int nr_tables)
for (i = 0; i < nr_tables; i++) {
entry = kzalloc(sizeof(struct amd_page_map), GFP_KERNEL);
if (entry == NULL) {
while (i > 0) {
kfree(tables[i-1]);
i--;
}
kfree(tables);
retval = -ENOMEM;
break;
}