Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 May 2012 16:33:58 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r236188 - head/sys/fs/nandfs
Message-ID:  <201205281633.q4SGXw51021816@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Mon May 28 16:33:58 2012
New Revision: 236188
URL: http://svn.freebsd.org/changeset/base/236188

Log:
  Catch a corner case where ssegs could be 0 and thus i would be 0 and
  we index suinfo out of bounds (i.e. -1).
  
  Approved by:	gber

Modified:
  head/sys/fs/nandfs/nandfs_cleaner.c

Modified: head/sys/fs/nandfs/nandfs_cleaner.c
==============================================================================
--- head/sys/fs/nandfs/nandfs_cleaner.c	Mon May 28 15:34:55 2012	(r236187)
+++ head/sys/fs/nandfs/nandfs_cleaner.c	Mon May 28 16:33:58 2012	(r236188)
@@ -310,23 +310,22 @@ retry:
 		nandfs_error("%s:%d", __FILE__, __LINE__);
 		goto out;
 	}
-
 	if (ssegs == 0 && *rseg != 0) {
 		*rseg = 0;
 		goto retry;
 	}
+	if (ssegs > 0) {
+		print_suinfo(suinfo, ssegs);
 
-	print_suinfo(suinfo, ssegs);
-
-	for (i = 0; i < ssegs; i++) {
-		(**segpp) = suinfo[i].nsi_num;
-		(*segpp)++;
+		for (i = 0; i < ssegs; i++) {
+			(**segpp) = suinfo[i].nsi_num;
+			(*segpp)++;
+		}
+		*rseg = suinfo[i - 1].nsi_num + 1;
 	}
 
-	*rseg = suinfo[i - 1].nsi_num + 1;
 out:
 	free(suinfo, M_NANDFSTEMP);
-
 	return (error);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205281633.q4SGXw51021816>