Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102628979
D38006.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D38006.diff
View Options
diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c
--- a/stand/libsa/zfs/zfs.c
+++ b/stand/libsa/zfs/zfs.c
@@ -379,9 +379,9 @@
static int
zfs_mount(const char *dev, const char *path, void **data)
{
- struct zfs_devdesc *zfsdev;
+ struct zfs_devdesc *zfsdev = NULL;
spa_t *spa;
- struct zfsmount *mnt;
+ struct zfsmount *mnt = NULL;
int rv;
errno = 0;
@@ -391,36 +391,46 @@
}
spa = spa_find_by_dev(zfsdev);
- if (spa == NULL)
- return (ENXIO);
+ if (spa == NULL) {
+ rv = ENXIO;
+ goto err;
+ }
mnt = calloc(1, sizeof(*mnt));
- if (mnt != NULL && path != NULL)
+ if (mnt == NULL) {
+ rv = ENOMEM;
+ goto err;
+ }
+
+ if (mnt->path != NULL) {
mnt->path = strdup(path);
- rv = errno;
+ if (mnt->path == NULL) {
+ rv = ENOMEM;
+ goto err;
+ }
+ }
- if (mnt != NULL)
- rv = zfs_mount_impl(spa, zfsdev->root_guid, mnt);
- free(zfsdev);
+ rv = zfs_mount_impl(spa, zfsdev->root_guid, mnt);
- if (rv == 0 && mnt != NULL && mnt->objset.os_type != DMU_OST_ZFS) {
+ if (rv == 0 && mnt->objset.os_type != DMU_OST_ZFS) {
printf("Unexpected object set type %ju\n",
(uintmax_t)mnt->objset.os_type);
rv = EIO;
}
-
+err:
if (rv != 0) {
if (mnt != NULL)
free(mnt->path);
free(mnt);
+ free(zfsdev);
return (rv);
}
- if (mnt != NULL) {
- *data = mnt;
- if (path != NULL)
- STAILQ_INSERT_TAIL(&zfsmount, mnt, next);
- }
+ *data = mnt;
+ if (path != NULL)
+ STAILQ_INSERT_TAIL(&zfsmount, mnt, next);
+
+ free(zfsdev);
return (rv);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 1:23 AM (21 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14650513
Default Alt Text
D38006.diff (1 KB)
Attached To
Mode
D38006: stand/zfs: Fix memory leaking on error cases
Attached
Detach File
Event Timeline
Log In to Comment