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)
Mon, Nov 25, 12:16 PM
Unknown Object (File)
Fri, Nov 15, 5:00 AM
Unknown Object (File)
Fri, Nov 15, 4:45 AM
Unknown Object (File)
Fri, Nov 15, 4:08 AM
Unknown Object (File)
Fri, Nov 15, 3:30 AM
Unknown Object (File)
Fri, Nov 15, 1:23 AM
Unknown Object (File)
Fri, Nov 1, 4:32 AM
Unknown Object (File)
Fri, Nov 1, 4:10 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 Not Applicable
Unit
Tests Not Applicable

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.