Don't invoke semunload() if seminit() fails during MOD_LOAD.

The module handler code invokes a MOD_UNLOAD event immediately if
MOD_LOAD fails.  The result was that if seminit() failed, semunload()
was invoked twice.  semunload() is not idempotent however and would
try to remove it's process_exit eventhandler twice resulting in a
panic.

Reviewed by:	kib, markj
Obtained from:	CheriBSD
MFC after:	1 month
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26696
This commit is contained in:
John Baldwin 2020-10-09 20:20:42 +00:00
parent 3d265fce43
commit 7e8bd70cff

View File

@ -381,8 +381,6 @@ sysvsem_modload(struct module *module, int cmd, void *arg)
switch (cmd) {
case MOD_LOAD:
error = seminit();
if (error != 0)
semunload();
break;
case MOD_UNLOAD:
error = semunload();