Commit c30efbae authored by Dave Jones's avatar Dave Jones

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

If we fail an alloc, unwind the previous allocs that succeeded.
Spotted-by: default avatarAlan Grimes <agrimes@speakeasy.net>
Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 4b95320f
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment