From: Ben Gras Date: Wed, 19 Sep 2012 14:57:27 +0000 (+0200) Subject: vfs: pm_dumpcore: always clean up process X-Git-Tag: v3.2.1~315 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/cppcheck-error.log?a=commitdiff_plain;h=60014efb3e85bbaf66170d4cf7b9fb7655556920;p=minix.git vfs: pm_dumpcore: always clean up process . whenever this function is called, pm will expect the process to be cleaned up . so don't abort the process entirely on error . fixes a later 'forking on top of in-use child' vfs panic --- diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index eaae794a9..04c799f71 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -695,7 +695,7 @@ int do_svrctl() *===========================================================================*/ int pm_dumpcore(endpoint_t proc_e, int csig, vir_bytes exe_name) { - int slot, r, core_fd; + int slot, r = OK, core_fd; struct filp *f; char core_path[PATH_MAX]; char proc_name[PROC_NAME_LEN]; @@ -706,22 +706,23 @@ int pm_dumpcore(endpoint_t proc_e, int csig, vir_bytes exe_name) /* open core file */ snprintf(core_path, PATH_MAX, "%s.%d", CORE_NAME, fp->fp_pid); core_fd = common_open(core_path, O_WRONLY | O_CREAT | O_TRUNC, CORE_MODE); - if (core_fd < 0) return(core_fd); + if (core_fd < 0) { r = core_fd; goto core_exit; } /* get process' name */ r = sys_datacopy(PM_PROC_NR, exe_name, VFS_PROC_NR, (vir_bytes) proc_name, PROC_NAME_LEN); - if (r != OK) return(r); + if (r != OK) goto core_exit; proc_name[PROC_NAME_LEN - 1] = '\0'; - if ((f = get_filp(core_fd, VNODE_WRITE)) == NULL) return(EBADF); + if ((f = get_filp(core_fd, VNODE_WRITE)) == NULL) { r=EBADF; goto core_exit; } write_elf_core_file(f, csig, proc_name); unlock_filp(f); (void) close_fd(fp, core_fd); /* ignore failure, we're exiting anyway */ +core_exit: if(csig) free_proc(fp, FP_EXITING); - return(OK); + return(r); } /*===========================================================================*