]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sparc64: __init code no longer called during non __init
authorAllen Pais <allen.pais@oracle.com>
Fri, 2 Jan 2015 05:18:41 +0000 (10:48 +0530)
committerAllen Pais <allen.pais@oracle.com>
Wed, 9 Sep 2015 18:42:15 +0000 (00:12 +0530)
mdesc_update calling __init memory free code through a pointer at
non-init time. Since text page was already given back and reused
this results in an illegal instruction trap. Was not caught by
linker section mismatch checks due to pointer indirection.

This patch NULL's out mops pointer after __init time and then
checks for non-NULL before calling mops->free.

Signed-off-by: Chris Hyser <chris.hyser@oracle.com>
Acked-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Acked-by: Bob Picco <bob.picco@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
(cherry picked from commit 6dbae4a0137d7855472c4845b5db11cffa32efc1)
(cherry picked from commit f0673a413f04de21963ab7f3912eb9a84c52c66e)

arch/sparc/kernel/mdesc.c

index 6f80936e0eea4d0dab82966b8f69cd7e6127b1dd..b9fe42450308cc45a4e47b2483225eebd1c46891 100644 (file)
@@ -178,7 +178,8 @@ static struct mdesc_handle *mdesc_alloc(unsigned int mdesc_size,
 
 static void mdesc_free(struct mdesc_handle *hp)
 {
-       hp->mops->free(hp);
+       if (hp->mops)
+               hp->mops->free(hp);
 }
 
 static struct mdesc_handle *cur_mdesc;
@@ -207,7 +208,7 @@ void mdesc_release(struct mdesc_handle *hp)
        spin_lock_irqsave(&mdesc_lock, flags);
        if (atomic_dec_and_test(&hp->refcnt)) {
                list_del_init(&hp->list);
-               hp->mops->free(hp);
+               mdesc_free(hp);
        }
        spin_unlock_irqrestore(&mdesc_lock, flags);
 }
@@ -1108,6 +1109,8 @@ void __init sun4v_mdesc_init(void)
                prom_halt();
        }
 
+       /* current 'mops' pointers are dangerous if not __init code */
+       hp->mops = NULL;
        cur_mdesc = hp;
 
        report_platform_properties();