aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/irqchip
diff options
context:
space:
mode:
authorShanker Donthineni <shankerd@codeaurora.org>2016-02-01 21:19:44 -0500
committerThomas Gleixner <tglx@linutronix.de>2016-02-04 09:14:50 -0500
commit1a485f4d2e28efd77075b2952926683d6c245633 (patch)
tree3088dd5ab2953ebba071e45caece4e901da470bd /drivers/irqchip
parent6235f0ecc4ed799169b80f7317c7f974f7415320 (diff)
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: Shanker Donthineni <shankerd@codeaurora.org> Acked-by: Marc 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.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/irqchip')
-rw-r--r--drivers/irqchip/irq-gic-v3-its.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 3447549fcc93..0a73632b28d5 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -66,7 +66,10 @@ struct its_node {
66 unsigned long phys_base; 66 unsigned long phys_base;
67 struct its_cmd_block *cmd_base; 67 struct its_cmd_block *cmd_base;
68 struct its_cmd_block *cmd_write; 68 struct its_cmd_block *cmd_write;
69 void *tables[GITS_BASER_NR_REGS]; 69 struct {
70 void *base;
71 u32 order;
72 } tables[GITS_BASER_NR_REGS];
70 struct its_collection *collections; 73 struct its_collection *collections;
71 struct list_head its_device_list; 74 struct list_head its_device_list;
72 u64 flags; 75 u64 flags;
@@ -807,9 +810,10 @@ static void its_free_tables(struct its_node *its)
807 int i; 810 int i;
808 811
809 for (i = 0; i < GITS_BASER_NR_REGS; i++) { 812 for (i = 0; i < GITS_BASER_NR_REGS; i++) {
810 if (its->tables[i]) { 813 if (its->tables[i].base) {
811 free_page((unsigned long)its->tables[i]); 814 free_pages((unsigned long)its->tables[i].base,
812 its->tables[i] = NULL; 815 its->tables[i].order);
816 its->tables[i].base = NULL;
813 } 817 }
814 } 818 }
815} 819}
@@ -890,7 +894,8 @@ retry_alloc_baser:
890 goto out_free; 894 goto out_free;
891 } 895 }
892 896
893 its->tables[i] = base; 897 its->tables[i].base = base;
898 its->tables[i].order = order;
894 899
895retry_baser: 900retry_baser:
896 val = (virt_to_phys(base) | 901 val = (virt_to_phys(base) |
@@ -940,7 +945,7 @@ retry_baser:
940 * something is horribly wrong... 945 * something is horribly wrong...
941 */ 946 */
942 free_pages((unsigned long)base, order); 947 free_pages((unsigned long)base, order);
943 its->tables[i] = NULL; 948 its->tables[i].base = NULL;
944 949
945 switch (psz) { 950 switch (psz) {
946 case SZ_16K: 951 case SZ_16K: