Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Nov 2019 15:04:00 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r354593 - head/stand/libsa/zfs
Message-ID:  <201911101504.xAAF40ZD062032@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Sun Nov 10 15:03:59 2019
New Revision: 354593
URL: https://svnweb.freebsd.org/changeset/base/354593

Log:
  loader: memory leak in vdev_label_read_config()
  
  We need to free the allocated buffer for label.

Modified:
  head/stand/libsa/zfs/zfsimpl.c

Modified: head/stand/libsa/zfs/zfsimpl.c
==============================================================================
--- head/stand/libsa/zfs/zfsimpl.c	Sun Nov 10 10:03:22 2019	(r354592)
+++ head/stand/libsa/zfs/zfsimpl.c	Sun Nov 10 15:03:59 2019	(r354593)
@@ -1622,10 +1622,8 @@ vdev_label_read_config(vdev_t *vd, uint64_t txg)
 
 	nvl_size = VDEV_PHYS_SIZE - sizeof (zio_eck_t) - 4;
 	nvl = malloc(nvl_size);
-	if (nvl == NULL) {
-		free(label);
-		return (NULL);
-	}
+	if (nvl == NULL)
+		goto done;
 
 	for (int l = 0; l < VDEV_LABELS; l++) {
 		const unsigned char *nvlist;
@@ -1643,7 +1641,7 @@ vdev_label_read_config(vdev_t *vd, uint64_t txg)
 		    DATA_TYPE_UINT64, NULL, &label_txg);
 		if (error != 0 || label_txg == 0) {
 			memcpy(nvl, nvlist, nvl_size);
-			return (nvl);
+			goto done;
 		}
 
 		if (label_txg <= txg && label_txg > best_txg) {
@@ -1666,6 +1664,8 @@ vdev_label_read_config(vdev_t *vd, uint64_t txg)
 		free(nvl);
 		nvl = NULL;
 	}
+done:
+	free(label);
 	return (nvl);
 }
 



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