1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-13 10:02:38 +00:00

loader: memory leak in vdev_label_read_config()

We need to free the allocated buffer for label.
This commit is contained in:
Toomas Soome 2019-11-10 15:03:59 +00:00
parent 415d23ebfd
commit 3cac32d147
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354593

View File

@ -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);
}