Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/ntfs Fix a node leak.



details:   https://anonhg.NetBSD.org/src/rev/24687bc837d5
branches:  trunk
changeset: 335587:24687bc837d5
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri Jan 16 17:02:12 2015 +0000

description:
Fix a node leak.

Sent on tech-kern@, tested by martin@

diffstat:

 sys/fs/ntfs/ntfs_subr.c |  26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diffs (70 lines):

diff -r 9dd1bb4707a0 -r 24687bc837d5 sys/fs/ntfs/ntfs_subr.c
--- a/sys/fs/ntfs/ntfs_subr.c   Fri Jan 16 10:37:51 2015 +0000
+++ b/sys/fs/ntfs/ntfs_subr.c   Fri Jan 16 17:02:12 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_subr.c,v 1.58 2015/01/06 11:04:00 hannken Exp $   */
+/*     $NetBSD: ntfs_subr.c,v 1.59 2015/01/16 17:02:12 maxv Exp $      */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko (semenu%FreeBSD.org@localhost)
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.58 2015/01/06 11:04:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.59 2015/01/16 17:02:12 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -756,9 +756,9 @@
 {
        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 */
-       void *        rdbuf;    /* Buffer to read directory's blocks  */
+       void *        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;
@@ -776,8 +776,10 @@
                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]
@@ -963,9 +965,11 @@
                        free(tctx, M_TEMP);
                }
        }
-       ntfs_ntvattrrele(vap);
+       if (vap)
+               ntfs_ntvattrrele(vap);
+       if (rdbuf)
+               free(rdbuf, M_TEMP);
        ntfs_ntput(ip);
-       free(rdbuf, M_TEMP);
        return (error);
 }
 
@@ -1026,8 +1030,10 @@
                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;



Home | Main Index | Thread Index | Old Index