diff options
author | Dave Jones <davej@redhat.com> | 2007-01-28 23:39:19 +0100 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2007-01-28 23:39:19 +0100 |
commit | c30efbaeaa9297fb1a35ef952350e0c2bb7a3d47 (patch) | |
tree | 66d369f957a04845883929662cb3d1151ece8923 | |
parent | [AGPGART] intel_agp: restore graphics device's pci space early in resume (diff) | |
download | linux-c30efbaeaa9297fb1a35ef952350e0c2bb7a3d47.tar.xz linux-c30efbaeaa9297fb1a35ef952350e0c2bb7a3d47.zip |
[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>
-rw-r--r-- | drivers/char/agp/amd-k7-agp.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c index 51d0d562d01e..c85c8cadb6df 100644 --- a/drivers/char/agp/amd-k7-agp.c +++ b/drivers/char/agp/amd-k7-agp.c @@ -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; } |