diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2013-01-03 16:13:17 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2013-01-03 16:13:17 +0000 |
commit | 696498a3f5afb674415c746edc87f5a3dd2f9d2d (patch) | |
tree | 36e98179b7f87f700e4c67df2cb8dd0e30ba3001 /sys/ntfs | |
parent | 48d7a9c8ab9b5285bde529597029762b39331c00 (diff) |
Correct error handling in two hard to hit ENOTDIR error cases. These would
previously leave the ntnode locked and neglect to decrement the use count.
ok krw@ miod@
Diffstat (limited to 'sys/ntfs')
-rw-r--r-- | sys/ntfs/ntfs_subr.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c index a5e694af740..9b87873bc34 100644 --- a/sys/ntfs/ntfs_subr.c +++ b/sys/ntfs/ntfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_subr.c,v 1.26 2013/01/02 08:12:13 jsing Exp $ */ +/* $OpenBSD: ntfs_subr.c,v 1.27 2013/01/03 16:13:16 jsing Exp $ */ /* $NetBSD: ntfs_subr.c,v 1.4 2003/04/10 21:37:32 jdolecek Exp $ */ /*- @@ -854,9 +854,9 @@ ntfs_ntlookupfile( { struct fnode *fp = VTOF(vp); struct ntnode *ip = FTONT(fp); - struct ntvattr *vap; /* Root attribute */ + struct ntvattr *vap = NULL; /* Root attribute */ cn_t cn = 0; /* VCN in current attribute */ - caddr_t rdbuf; /* Buffer to read directory's blocks */ + caddr_t rdbuf = NULL; /* Buffer to read directory's blocks */ u_int32_t blsize; u_int32_t rdsize; /* Length of data to read from current block */ struct attr_indexentry *iep; @@ -872,13 +872,14 @@ ntfs_ntlookupfile( struct ntfs_lookup_ctx *lookup_ctx = NULL, *tctx; error = ntfs_ntget(ip, p); - if (error) return (error); error = ntfs_ntvattrget(ntmp, ip, NTFS_A_INDXROOT, "$I30", 0, &vap); - if (error || (vap->va_flag & NTFS_AF_INRUN)) - return (ENOTDIR); + if (error || (vap->va_flag & NTFS_AF_INRUN)) { + error = ENOTDIR; + goto fail; + } /* * Divide file name into: foofilefoofilefoofile[:attrspec] @@ -1094,6 +1095,10 @@ ntfs_ntlookupfile( dprintf(("finish\n")); fail: + if (vap) + ntfs_ntvattrrele(vap); + if (rdbuf) + free(rdbuf, M_TEMP); if (attrname) free(attrname, M_TEMP); if (lookup_ctx) { @@ -1103,9 +1108,7 @@ fail: free(tctx, M_TEMP); } } - ntfs_ntvattrrele(vap); ntfs_ntput(ip, p); - free(rdbuf, M_TEMP); return (error); } @@ -1172,8 +1175,10 @@ ntfs_ntreaddir( return (error); error = ntfs_ntvattrget(ntmp, ip, NTFS_A_INDXROOT, "$I30", 0, &vap); - if (error) - return (ENOTDIR); + if (error) { + error = ENOTDIR; + goto fail; + } if (fp->f_dirblbuf == NULL) { fp->f_dirblsz = vap->va_a_iroot->ir_size; |