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
F102628979: D38006.diff
Fri, Nov 15, 1:23 AM
Unknown Object (File)
Fri, Nov 1, 4:32 AM
Unknown Object (File)
Fri, Nov 1, 4:10 AM
Unknown Object (File)
Tue, Oct 22, 1:39 PM
Unknown Object (File)
Tue, Oct 22, 1:39 PM
Unknown Object (File)
Tue, Oct 22, 1:38 PM
Unknown Object (File)
Tue, Oct 22, 1:38 PM
Unknown Object (File)
Tue, Oct 22, 1:38 PM
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 49087
Build 45976: arc lint + arc unit

Event Timeline

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

We should probably error-check this as well?

stand/libsa/zfs/zfs.c
406–411

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
411–416

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.