Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Check fc_type before fc_cluster, because the latter ...



details:   https://anonhg.NetBSD.org/src/rev/b75cf61b57e7
branches:  trunk
changeset: 964554:b75cf61b57e7
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Aug 07 10:36:19 2019 +0000

description:
Check fc_type before fc_cluster, because the latter may not be initialized.
This is harmless because fc_type is always initialized properly, so the
next branch wouldn't have been taken.

diffstat:

 sys/dev/fss.c |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (42 lines):

diff -r b440f087b65b -r b75cf61b57e7 sys/dev/fss.c
--- a/sys/dev/fss.c     Wed Aug 07 10:12:32 2019 +0000
+++ b/sys/dev/fss.c     Wed Aug 07 10:36:19 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fss.c,v 1.107 2019/02/20 10:03:25 hannken Exp $        */
+/*     $NetBSD: fss.c,v 1.108 2019/08/07 10:36:19 maxv Exp $   */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.107 2019/02/20 10:03:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.108 2019/08/07 10:36:19 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -992,16 +992,19 @@
                return 0;
        }
 
-       for (scp = sc->sc_cache; scp < scl; scp++)
-               if (scp->fc_cluster == cl) {
-                       if (scp->fc_type == FSS_CACHE_VALID) {
+       for (scp = sc->sc_cache; scp < scl; scp++) {
+               if (scp->fc_type == FSS_CACHE_VALID) {
+                       if (scp->fc_cluster == cl) {
                                mutex_exit(&sc->sc_slock);
                                return 0;
-                       } else if (scp->fc_type == FSS_CACHE_BUSY) {
+                       }
+               } else if (scp->fc_type == FSS_CACHE_BUSY) {
+                       if (scp->fc_cluster == cl) {
                                cv_wait(&scp->fc_state_cv, &sc->sc_slock);
                                goto restart;
                        }
                }
+       }
 
        for (scp = sc->sc_cache; scp < scl; scp++)
                if (scp->fc_type == FSS_CACHE_FREE) {



Home | Main Index | Thread Index | Old Index