module: convert to stop_machine_create/destroy.

The module code relies on a non-failing stop_machine call. So we create
the kstop threads in advance and with that make sure the call won't fail.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

authored by

Heiko Carstens and committed by
Rusty Russell
9e01892c 9ea09af3

+21 -2
+21 -2
kernel/module.c
··· 757 757 return -EFAULT; 758 758 name[MODULE_NAME_LEN-1] = '\0'; 759 759 760 - if (mutex_lock_interruptible(&module_mutex) != 0) 761 - return -EINTR; 760 + /* Create stop_machine threads since free_module relies on 761 + * a non-failing stop_machine call. */ 762 + ret = stop_machine_create(); 763 + if (ret) 764 + return ret; 765 + 766 + if (mutex_lock_interruptible(&module_mutex) != 0) { 767 + ret = -EINTR; 768 + goto out_stop; 769 + } 762 770 763 771 mod = find_module(name); 764 772 if (!mod) { ··· 825 817 826 818 out: 827 819 mutex_unlock(&module_mutex); 820 + out_stop: 821 + stop_machine_destroy(); 828 822 return ret; 829 823 } 830 824 ··· 1885 1875 /* vmalloc barfs on "unusual" numbers. Check here */ 1886 1876 if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL) 1887 1877 return ERR_PTR(-ENOMEM); 1878 + 1879 + /* Create stop_machine threads since the error path relies on 1880 + * a non-failing stop_machine call. */ 1881 + err = stop_machine_create(); 1882 + if (err) 1883 + goto free_hdr; 1884 + 1888 1885 if (copy_from_user(hdr, umod, len) != 0) { 1889 1886 err = -EFAULT; 1890 1887 goto free_hdr; ··· 2275 2258 /* Get rid of temporary copy */ 2276 2259 vfree(hdr); 2277 2260 2261 + stop_machine_destroy(); 2278 2262 /* Done! */ 2279 2263 return mod; 2280 2264 ··· 2298 2280 kfree(args); 2299 2281 free_hdr: 2300 2282 vfree(hdr); 2283 + stop_machine_destroy(); 2301 2284 return ERR_PTR(err); 2302 2285 2303 2286 truncated: