[PATCH] intel-gtt: fix an error handle in i810_setup()

Haoxiang Li posted 1 patch 1 week, 5 days ago
drivers/char/agp/intel-gtt.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] intel-gtt: fix an error handle in i810_setup()
Posted by Haoxiang Li 1 week, 5 days ago
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: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 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
Re: [PATCH] intel-gtt: fix an error handle in i810_setup()
Posted by Markus Elfring 1 week, 4 days ago
> In i810_setup(), if ioremap() fails, the memory allocated
> by alloc_gatt_pages() should be freed. Add free_gatt_pages()
> to do so.

* Were any source code analysis tools involved here?

* Would the term “exception handling” be more appropriate than “an error handle”?


Regards,
Markus