Skip to content

Commit

Permalink
[AGPGART] Prevent (unlikely) memory leak in amd_create_gatt_pages()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dave Jones committed Jan 28, 2007
1 parent 4b95320 commit c30efba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/char/agp/amd-k7-agp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c30efba

Please sign in to comment.