Page MenuHomeFreeBSD

stand/zfs: Fix memory leaking on error cases
ClosedPublic

Authored by imp on Jan 10 2023, 12:18 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 21, 12:04 AM
Unknown Object (File)
Fri, Jun 14, 3:18 AM
Unknown Object (File)
Fri, Jun 14, 3:18 AM
Unknown Object (File)
Fri, Jun 14, 3:18 AM
Unknown Object (File)
Fri, Jun 14, 3:18 AM
Unknown Object (File)
Fri, Jun 14, 3:18 AM
Unknown Object (File)
Fri, Jun 14, 3:18 AM
Unknown Object (File)
Fri, Jun 14, 2:56 AM
Subscribers

Details

Summary

Now that we return an allocated zfs_devdesc, we have to free it. These
frees were missing from the error cases. In addition, simplify the code
a bit for the out of memory case.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 49056
Build 45945: arc lint + arc unit

Event Timeline

imp requested review of this revision.Jan 10 2023, 12:18 AM
stand/libsa/zfs/zfs.c
399–409

We should probably error-check this as well?

stand/libsa/zfs/zfs.c
399–409

yea, and do what I wonder... I'm guessing return ENOMEM... though I need to understand better when path == NULL

Turns out path can't be NULL here (it would have been dereferenced in mount()
unconditionally).

So, if strdup returns NULL, bail with ENOMEM after freeing stuff.

This revision is now accepted and ready to land.Jan 12 2023, 5:28 AM
stand/libsa/zfs/zfs.c
404–409

hmmm, this needs a minor change...

path can be null, so cope with that
Also, add a generic exit path for the error case

This revision now requires review to proceed.Jan 13 2023, 3:28 PM
This revision is now accepted and ready to land.Jan 13 2023, 7:44 PM
This revision was automatically updated to reflect the committed changes.