In i810_setup(), if ioremap() fails, the memory allocated
by alloc_gatt_pages() should be freed. Add free_gatt_pages()
to do so.

Fixes: 820647b97a9c ("intel-gtt: switch i81x to the common initialization 
helpers")
Cc: [email protected]
Signed-off-by: Haoxiang Li <[email protected]>
---
 drivers/char/agp/intel-gtt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index bcc26785175d..dfb6282ce401 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -186,8 +186,10 @@ static int i810_setup(void)
        reg_addr = pci_resource_start(intel_private.pcidev, I810_MMADR_BAR);
 
        intel_private.registers = ioremap(reg_addr, KB(64));
-       if (!intel_private.registers)
+       if (!intel_private.registers) {
+               free_gatt_pages(intel_private.i81x_gtt_table, I810_GTT_ORDER);
                return -ENOMEM;
+       }
 
        writel(virt_to_phys(gtt_table) | I810_PGETBL_ENABLED,
               intel_private.registers+I810_PGETBL_CTL);
-- 
2.25.1

Reply via email to