svn commit: r353985 - stable/12/stand/libsa/zfs

Kyle Evans kevans at FreeBSD.org
Thu Oct 24 03:06:38 UTC 2019


Author: kevans
Date: Thu Oct 24 03:06:37 2019
New Revision: 353985
URL: https://svnweb.freebsd.org/changeset/base/353985

Log:
  MFC r348352, r348354
  
  r348352:
  loader: zfs_alloc and zfs_free should use panic
  
  The zfs alloc and free code print out the error and get stuck in infinite
  loop; use panic() instead.
  
  r348354:
  loader: malloc+memset is calloc in spa_create
  
  Replace malloc + memset pair with calloc.

Modified:
  stable/12/stand/libsa/zfs/zfsimpl.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/stand/libsa/zfs/zfsimpl.c
==============================================================================
--- stable/12/stand/libsa/zfs/zfsimpl.c	Thu Oct 24 03:04:36 2019	(r353984)
+++ stable/12/stand/libsa/zfs/zfsimpl.c	Thu Oct 24 03:06:37 2019	(r353985)
@@ -174,8 +174,7 @@ zfs_alloc(size_t size)
 	char *ptr;
 
 	if (zfs_temp_ptr + size > zfs_temp_end) {
-		printf("ZFS: out of temporary buffer space\n");
-		for (;;) ;
+		panic("ZFS: out of temporary buffer space");
 	}
 	ptr = zfs_temp_ptr;
 	zfs_temp_ptr += size;
@@ -189,8 +188,7 @@ zfs_free(void *ptr, size_t size)
 
 	zfs_temp_ptr -= size;
 	if (zfs_temp_ptr != ptr) {
-		printf("ZFS: zfs_alloc()/zfs_free() mismatch\n");
-		for (;;) ;
+		panic("ZFS: zfs_alloc()/zfs_free() mismatch");
 	}
 }
 
@@ -1341,9 +1339,8 @@ spa_create(uint64_t guid, const char *name)
 {
 	spa_t *spa;
 
-	if ((spa = malloc(sizeof(spa_t))) == NULL)
+	if ((spa = calloc(1, sizeof(spa_t))) == NULL)
 		return (NULL);
-	memset(spa, 0, sizeof(spa_t));
 	if ((spa->spa_name = strdup(name)) == NULL) {
 		free(spa);
 		return (NULL);


More information about the svn-src-stable-12 mailing list