Commit 1a485f4d authored by Shanker Donthineni's avatar Shanker Donthineni Committed by Thomas Gleixner

irqchip/gicv3-its: Fix memory leak in its_free_tables()

The current ITS driver has a memory leak in its_free_tables(). It
happens on tear down path of the driver when its_probe() call fails.
its_free_tables() should free the exact number of pages that have
been allocated, not just a single page as current code does.

This patch records the memory size for each ITS_BASERn at the time of
page allocation and uses the same size information when freeing pages
to fix the issue.
Signed-off-by: default avatarShanker Donthineni <shankerd@codeaurora.org>
Acked-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Vikram Sethi <vikrams@codeaurora.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1454379584-21772-1-git-send-email-shankerd@codeaurora.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 6235f0ec
...@@ -66,7 +66,10 @@ struct its_node { ...@@ -66,7 +66,10 @@ struct its_node {
unsigned long phys_base; unsigned long phys_base;
struct its_cmd_block *cmd_base; struct its_cmd_block *cmd_base;
struct its_cmd_block *cmd_write; struct its_cmd_block *cmd_write;
void *tables[GITS_BASER_NR_REGS]; struct {
void *base;
u32 order;
} tables[GITS_BASER_NR_REGS];
struct its_collection *collections; struct its_collection *collections;
struct list_head its_device_list; struct list_head its_device_list;
u64 flags; u64 flags;
...@@ -807,9 +810,10 @@ static void its_free_tables(struct its_node *its) ...@@ -807,9 +810,10 @@ static void its_free_tables(struct its_node *its)
int i; int i;
for (i = 0; i < GITS_BASER_NR_REGS; i++) { for (i = 0; i < GITS_BASER_NR_REGS; i++) {
if (its->tables[i]) { if (its->tables[i].base) {
free_page((unsigned long)its->tables[i]); free_pages((unsigned long)its->tables[i].base,
its->tables[i] = NULL; its->tables[i].order);
its->tables[i].base = NULL;
} }
} }
} }
...@@ -890,7 +894,8 @@ static int its_alloc_tables(const char *node_name, struct its_node *its) ...@@ -890,7 +894,8 @@ static int its_alloc_tables(const char *node_name, struct its_node *its)
goto out_free; goto out_free;
} }
its->tables[i] = base; its->tables[i].base = base;
its->tables[i].order = order;
retry_baser: retry_baser:
val = (virt_to_phys(base) | val = (virt_to_phys(base) |
...@@ -940,7 +945,7 @@ static int its_alloc_tables(const char *node_name, struct its_node *its) ...@@ -940,7 +945,7 @@ static int its_alloc_tables(const char *node_name, struct its_node *its)
* something is horribly wrong... * something is horribly wrong...
*/ */
free_pages((unsigned long)base, order); free_pages((unsigned long)base, order);
its->tables[i] = NULL; its->tables[i].base = NULL;
switch (psz) { switch (psz) {
case SZ_16K: case SZ_16K:
......
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