Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/ufs Fix uninitialized mutex usage



details:   https://anonhg.NetBSD.org/src/rev/25549480b7d0
branches:  trunk
changeset: 803998:25549480b7d0
user:      manu <manu%NetBSD.org@localhost>
date:      Wed Nov 19 16:26:47 2014 +0000

description:
Fix uninitialized mutex usage

We use extended attribute mount mutex before testing if it had been
initialized, and as reported by Christos,  this caused panic with
LOCKDEBUG. Fix it by testing before using.

diffstat:

 sys/ufs/ufs/ufs_extattr.c |  36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diffs (114 lines):

diff -r 0f3a799ab34d -r 25549480b7d0 sys/ufs/ufs/ufs_extattr.c
--- a/sys/ufs/ufs/ufs_extattr.c Wed Nov 19 14:25:00 2014 +0000
+++ b/sys/ufs/ufs/ufs_extattr.c Wed Nov 19 16:26:47 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp $    */
+/*     $NetBSD: ufs_extattr.c,v 1.46 2014/11/19 16:26:47 manu Exp $    */
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.46 2014/11/19 16:26:47 manu Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -1103,6 +1103,9 @@
        struct ufsmount *ump = VFSTOUFS(mp);
        int error;
 
+       if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
+               return (EOPNOTSUPP);
+
        ufs_extattr_uepm_lock(ump);
 
        error = ufs_extattr_get(ap->a_vp, ap->a_attrnamespace, ap->a_name,
@@ -1129,9 +1132,6 @@
        size_t len, old_len;
        int error = 0;
 
-       if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
-               return (EOPNOTSUPP);
-
        if (strlen(name) == 0)
                return (EINVAL);
 
@@ -1221,6 +1221,9 @@
        struct ufsmount *ump = VFSTOUFS(mp);
        int error;
 
+       if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
+               return (EOPNOTSUPP);
+
        ufs_extattr_uepm_lock(ump);
 
        error = ufs_extattr_list(ap->a_vp, ap->a_attrnamespace,
@@ -1247,9 +1250,6 @@
        size_t listsize = 0;
        int error = 0;
 
-       if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
-               return (EOPNOTSUPP);
-
        /*
         * XXX: We can move this inside the loop and iterate on individual
         *      attributes.
@@ -1348,6 +1348,9 @@
        struct ufsmount *ump = VFSTOUFS(mp); 
        int error;
 
+       if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
+               return (EOPNOTSUPP);
+
        ufs_extattr_uepm_lock(ump);
 
        error = ufs_extattr_rm(ap->a_vp, ap->a_attrnamespace, ap->a_name,
@@ -1377,6 +1380,9 @@
        struct ufsmount *ump = VFSTOUFS(mp); 
        int error;
 
+       if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
+               return (EOPNOTSUPP);
+
        ufs_extattr_uepm_lock(ump);
 
        /*
@@ -1415,8 +1421,7 @@
 
        if (vp->v_mount->mnt_flag & MNT_RDONLY)
                return (EROFS);
-       if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
-               return (EOPNOTSUPP);
+
        if (!ufs_extattr_valid_attrname(attrnamespace, name))
                return (EINVAL);
 
@@ -1535,8 +1540,7 @@
 
        if (vp->v_mount->mnt_flag & MNT_RDONLY)  
                return (EROFS);
-       if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
-               return (EOPNOTSUPP);
+
        if (!ufs_extattr_valid_attrname(attrnamespace, name))
                return (EINVAL);
 
@@ -1609,12 +1613,10 @@
        if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_INITIALIZED))
                return;
 
-       ufs_extattr_uepm_lock(ump);
+       if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED))
+               return;
 
-       if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)) {
-               ufs_extattr_uepm_unlock(ump);
-               return;
-       }
+       ufs_extattr_uepm_lock(ump);
 
        LIST_FOREACH(uele, &ump->um_extattr.uepm_list, uele_entries)
                ufs_extattr_rm(vp, uele->uele_attrnamespace,



Home | Main Index | Thread Index | Old Index