puffs - fix possible null pointer dereference
authorAlex Hornung <ahornung@gmail.com>
Sat, 25 Feb 2012 19:27:41 +0000 (19:27 +0000)
committerAlex Hornung <ahornung@gmail.com>
Sat, 25 Feb 2012 19:28:20 +0000 (19:28 +0000)
Found-by: clang static analyzer
sys/vfs/puffs/puffs_vnops.c

index d04b8d4..9599b49 100644 (file)
@@ -111,7 +111,7 @@ puffs_vnop_lookup(struct vop_nresolve_args *ap)
        struct nchandle *nch = ap->a_nch;
        struct namecache *ncp = nch->ncp;
        struct ucred *cred = ap->a_cred;
-       struct vnode *vp, *dvp = ap->a_dvp;
+       struct vnode *vp = NULL, *dvp = ap->a_dvp;
        struct puffs_node *dpn;
        int error;
 
@@ -169,7 +169,7 @@ puffs_vnop_lookup(struct vop_nresolve_args *ap)
 
  out:
        vput(dvp);
-       if (!error) {
+       if (!error && vp != NULL) {
                vn_unlock(vp);
                cache_setvp(nch, vp);
                vrele(vp);