fix null deref; vmnt->mounted_on is NULL legitimately for root.

changed check+panic to assert().

added assert().
This commit is contained in:
Ben Gras 2010-03-29 11:39:54 +00:00
parent 5b52c5aa02
commit bc0e36f402

View file

@ -11,6 +11,7 @@
#include <minix/const.h> #include <minix/const.h>
#include <minix/endpoint.h> #include <minix/endpoint.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h>
#include <minix/vfsif.h> #include <minix/vfsif.h>
#include "fproc.h" #include "fproc.h"
#include "vmnt.h" #include "vmnt.h"
@ -43,6 +44,8 @@ int flags;
struct vmnt *vmp; struct vmnt *vmp;
struct node_details res; struct node_details res;
assert(dirp);
/* Get a free vnode */ /* Get a free vnode */
if((new_vp = get_free_vnode()) == NIL_VNODE) return(NIL_VNODE); if((new_vp = get_free_vnode()) == NIL_VNODE) return(NIL_VNODE);
@ -238,7 +241,7 @@ node_details_t *node;
dir_vp = 0; dir_vp = 0;
/* Start node is now the mounted partition's root node */ /* Start node is now the mounted partition's root node */
for (vmp = &vmnt[0]; vmp != &vmnt[NR_MNTS]; ++vmp) { for (vmp = &vmnt[0]; vmp != &vmnt[NR_MNTS]; ++vmp) {
if (vmp->m_dev != NO_DEV) { if (vmp->m_dev != NO_DEV && vmp->m_mounted_on) {
if (vmp->m_mounted_on->v_inode_nr == res.inode_nr && if (vmp->m_mounted_on->v_inode_nr == res.inode_nr &&
vmp->m_mounted_on->v_fs_e == res.fs_e) { vmp->m_mounted_on->v_fs_e == res.fs_e) {
dir_vp = vmp->m_root_node; dir_vp = vmp->m_root_node;
@ -246,10 +249,7 @@ node_details_t *node;
} }
} }
} }
assert(dir_vp);
if (!dir_vp) {
panic("VFS lookup: can't find mounted partition");
}
} else { } else {
/* Climbing up mount */ /* Climbing up mount */
/* Find the vmnt that represents the partition on /* Find the vmnt that represents the partition on