Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

um: embed ->stub_pages[] into mmu_context

seriously, kmalloc() for two-element array of pointers?

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro ea6fb417 104bb37d

+6 -19
+1 -1
arch/um/include/asm/mmu.h
··· 12 12 typedef struct mm_context { 13 13 struct mm_id id; 14 14 struct uml_arch_mm_context arch; 15 - struct page **stub_pages; 15 + struct page *stub_pages[2]; 16 16 } mm_context_t; 17 17 18 18 extern void __switch_mm(struct mm_id * mm_idp);
+5 -18
arch/um/kernel/skas/mmu.c
··· 92 92 goto out_free; 93 93 } 94 94 95 - to_mm->stub_pages = NULL; 96 - 97 95 return 0; 98 96 99 97 out_free: ··· 118 120 if (ret) 119 121 goto out; 120 122 121 - pages = kmalloc(2 * sizeof(struct page *), GFP_KERNEL); 122 - if (pages == NULL) { 123 - printk(KERN_ERR "arch_dup_mmap failed to allocate 2 page " 124 - "pointers\n"); 125 - goto out; 126 - } 127 - 128 - pages[0] = virt_to_page(&__syscall_stub_start); 129 - pages[1] = virt_to_page(mm->context.id.stack); 130 - mm->context.stub_pages = pages; 123 + mm->context.stub_pages[0] = virt_to_page(&__syscall_stub_start); 124 + mm->context.stub_pages[1] = virt_to_page(mm->context.id.stack); 131 125 132 126 /* dup_mmap already holds mmap_sem */ 133 127 err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START, 134 128 VM_READ | VM_MAYREAD | VM_EXEC | 135 - VM_MAYEXEC | VM_DONTCOPY, pages); 129 + VM_MAYEXEC | VM_DONTCOPY, 130 + mm->context.stub_pages); 136 131 if (err) { 137 132 printk(KERN_ERR "install_special_mapping returned %d\n", err); 138 - goto out_free; 133 + goto out; 139 134 } 140 135 return; 141 136 142 - out_free: 143 - kfree(pages); 144 137 out: 145 138 force_sigsegv(SIGSEGV, current); 146 139 } ··· 140 151 { 141 152 pte_t *pte; 142 153 143 - if (mm->context.stub_pages != NULL) 144 - kfree(mm->context.stub_pages); 145 154 pte = virt_to_pte(mm, STUB_CODE); 146 155 if (pte != NULL) 147 156 pte_clear(mm, STUB_CODE, pte);