DragonFlyBSD Kernel Audit
DF-1399 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/raid/vinum/vinumconfig.c b/sys/dev/raid/vinum/vinumconfig.c
--- a/sys/dev/raid/vinum/vinumconfig.c
+++ b/sys/dev/raid/vinum/vinumconfig.c
@@ -1532,18 +1532,19 @@
 
 	    case kw_prefer:
 		{
-		    int myplexno;			    /* index of this plex */
+		    int global_plexno;			    /* global index of this plex */
+		    int myplexno;			    /* local index in vol->plex[] */
 
-		    myplexno = find_plex(token[++parameter], 1); /* find a plex */
-		    if (myplexno < 0)			    /* couldn't */
+		    global_plexno = find_plex(token[++parameter], 1); /* find a plex */
+		    if (global_plexno < 0)		    /* couldn't */
 			break;				    /* we've already had an error message */
-		    myplexno = my_plex(volno, myplexno);    /* does it already belong to us? */
-		    if (myplexno > 0)			    /* yes */
+		    myplexno = my_plex(volno, global_plexno);  /* does it already belong to us? */
+		    if (myplexno >= 0)			    /* yes */
 			vol->preferred_plex = myplexno;	    /* just note the index */
 		    else if (++vol->plexes > 8)		    /* another entry */
 			throw_rude_remark(EINVAL, "Too many plexes");
 		    else {				    /* space for the new plex */
-			vol->plex[vol->plexes - 1] = myplexno; /* add it to our list */
+			vol->plex[vol->plexes - 1] = global_plexno; /* add it to our list */
 			vol->preferred_plex = vol->plexes - 1; /* and note the index */
 		    }
 		}