Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/ibcs2 Don't drop vnode ref until we're done with ...



details:   https://anonhg.NetBSD.org/src/rev/50dcd5269738
branches:  trunk
changeset: 825727:50dcd5269738
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Jul 29 01:05:54 2017 +0000

description:
Don't drop vnode ref until we're done with mount in ibcs2_stat(v)fs.

Nothing else guarantees the mount will stick around.

>From Ilja Van Sprundel.

diffstat:

 sys/compat/ibcs2/ibcs2_stat.c |  22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diffs (54 lines):

diff -r a700e303daf0 -r 50dcd5269738 sys/compat/ibcs2/ibcs2_stat.c
--- a/sys/compat/ibcs2/ibcs2_stat.c     Fri Jul 28 22:53:32 2017 +0000
+++ b/sys/compat/ibcs2/ibcs2_stat.c     Sat Jul 29 01:05:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ibcs2_stat.c,v 1.48 2014/09/05 09:21:54 matt Exp $     */
+/*     $NetBSD: ibcs2_stat.c,v 1.49 2017/07/29 01:05:54 riastradh Exp $        */
 /*
  * Copyright (c) 1995, 1998 Scott Bartram
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ibcs2_stat.c,v 1.48 2014/09/05 09:21:54 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibcs2_stat.c,v 1.49 2017/07/29 01:05:54 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -147,11 +147,13 @@
                return (error);
        mp = vp->v_mount;
        sp = &mp->mnt_stat;
+       if ((error = VFS_STATVFS(mp, sp)) != 0)
+               goto out;
+       sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
+       error = cvt_statfs(sp, (void *)SCARG(uap, buf), SCARG(uap, len));
+out:
        vrele(vp);
-       if ((error = VFS_STATVFS(mp, sp)) != 0)
-               return (error);
-       sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
-       return cvt_statfs(sp, (void *)SCARG(uap, buf), SCARG(uap, len));
+       return (error);
 }
 
 int
@@ -200,12 +202,14 @@
                return (error);
        mp = vp->v_mount;
        sp = &mp->mnt_stat;
-       vrele(vp);
        if ((error = VFS_STATVFS(mp, sp)) != 0)
                return (error);
        sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
-       return cvt_statvfs(sp, (void *)SCARG(uap, buf),
-                          sizeof(struct ibcs2_statvfs));
+       error = cvt_statvfs(sp, (void *)SCARG(uap, buf),
+           sizeof(struct ibcs2_statvfs));
+out:
+       vrele(vp);
+       return error;
 }
 
 int



Home | Main Index | Thread Index | Old Index