Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Aug 2014 05:17:24 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r270127 - in stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys
Message-ID:  <201408180517.s7I5HOWw055138@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Mon Aug 18 05:17:24 2014
New Revision: 270127
URL: http://svnweb.freebsd.org/changeset/base/270127

Log:
  MFC r269431: MFV r269427:
  
  In dnode_children_t, use C99's "[]" idiom for declaring the variable
  sized array dnc_children at the end of the structure.
  
  This prevents the compiler from mistakenly optimizing away accesses
  beyond the array's defined size.
  
  Illumos issue:
      5038 Remove "old-style" flexible array usage in ZFS.
      Author: Justin T. Gibbs <justing@spectralogic.com>

Modified:
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c	Mon Aug 18 05:13:46 2014	(r270126)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c	Mon Aug 18 05:17:24 2014	(r270127)
@@ -1026,7 +1026,7 @@ dnode_buf_pageout(dmu_buf_t *db, void *a
 		dnh->dnh_dnode = NULL;
 	}
 	kmem_free(children_dnodes, sizeof (dnode_children_t) +
-	    (epb - 1) * sizeof (dnode_handle_t));
+	    epb * sizeof (dnode_handle_t));
 }
 
 /*
@@ -1111,7 +1111,7 @@ dnode_hold_impl(objset_t *os, uint64_t o
 		int i;
 		dnode_children_t *winner;
 		children_dnodes = kmem_zalloc(sizeof (dnode_children_t) +
-		    (epb - 1) * sizeof (dnode_handle_t), KM_SLEEP);
+		    epb * sizeof (dnode_handle_t), KM_SLEEP);
 		children_dnodes->dnc_count = epb;
 		dnh = &children_dnodes->dnc_children[0];
 		for (i = 0; i < epb; i++) {
@@ -1126,7 +1126,7 @@ dnode_hold_impl(objset_t *os, uint64_t o
 			}
 
 			kmem_free(children_dnodes, sizeof (dnode_children_t) +
-			    (epb - 1) * sizeof (dnode_handle_t));
+			    epb * sizeof (dnode_handle_t));
 			children_dnodes = winner;
 		}
 	}

Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h	Mon Aug 18 05:13:46 2014	(r270126)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h	Mon Aug 18 05:17:24 2014	(r270127)
@@ -245,7 +245,7 @@ typedef struct dnode_handle {
 
 typedef struct dnode_children {
 	size_t dnc_count;		/* number of children */
-	dnode_handle_t dnc_children[1];	/* sized dynamically */
+	dnode_handle_t dnc_children[];	/* sized dynamically */
 } dnode_children_t;
 
 typedef struct free_range {



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