Source-Changes-HG archive

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

[src/pgoyette-localcount]: src/sys/kern Fix up the error/exit path.



details:   https://anonhg.NetBSD.org/src/rev/412e7072fd72
branches:  pgoyette-localcount
changeset: 852840:412e7072fd72
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Fri Jul 22 03:55:12 2016 +0000

description:
Fix up the error/exit path.

Return actual error, not blindly report success!

diffstat:

 sys/kern/vfs_mount.c |  22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diffs (63 lines):

diff -r 9a7594729269 -r 412e7072fd72 sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Fri Jul 22 03:44:36 2016 +0000
+++ b/sys/kern/vfs_mount.c      Fri Jul 22 03:55:12 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_mount.c,v 1.40.2.1 2016/07/20 23:47:57 pgoyette Exp $      */
+/*     $NetBSD: vfs_mount.c,v 1.40.2.2 2016/07/22 03:55:12 pgoyette Exp $      */
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.40.2.1 2016/07/20 23:47:57 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.40.2.2 2016/07/22 03:55:12 pgoyette Exp $");
 
 #define _VFS_VNODE_PRIVATE
 
@@ -1316,7 +1316,7 @@
 {
        vnode_t *bvp;
        dev_t dev;
-       int d_type, busy;
+       int d_type, ret;
        const struct cdevsw *cdev = NULL;
        const struct bdevsw *bdev = NULL;
 
@@ -1359,8 +1359,10 @@
                break;
        }
 
-       if (d_type != D_DISK)
-               return EINVAL;
+       if (d_type != D_DISK) {
+               ret = EINVAL;
+               goto out;
+       }
 
        if (bvpp != NULL)
                *bvpp = bvp;
@@ -1370,16 +1372,18 @@
         * XXX: not only if this specific slice is mounted, but
         * XXX: if it's on a disk with any other mounted slice.
         */
-       busy =vfs_mountedon(bvp);
+       if (vfs_mountedon(bvp) != 0)
+               ret = EBUSY;
+       else
+               ret = 0;
 
+ out:
        if (bdev != NULL)
                bdevsw_release(bdev);
        if (cdev != NULL)
                cdevsw_release(cdev);
 
-       if (busy)
-               return EBUSY;
-       return 0;
+       return ret;
 }
 
 /*



Home | Main Index | Thread Index | Old Index