mirror_zfs/lib
Richard Yao 72c99dc959
Handle possible null pointers from malloc/strdup/strndup()
GCC 12.1.1_p20220625's static analyzer caught these.

Of the two in the btree test, one had previously been caught by Coverity
and Smatch, but GCC flagged it as a false positive. Upon examining how
other test cases handle this, the solution was changed from
`ASSERT3P(node, !=, NULL);` to using `perror()` to be consistent with
the fixes to the other fixes done to the ZTS code.

That approach was also used in ZED since I did not see a better way of
handling this there. Also, upon inspection, additional unchecked
pointers from malloc()/calloc()/strdup() were found in ZED, so those
were handled too.

In other parts of the code, the existing methods to avoid issues from
memory allocators returning NULL were used, such as using
`umem_alloc(size, UMEM_NOFAIL)` or returning `ENOMEM`.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13979
2022-10-06 17:18:40 -07:00
..
libavl cppcheck: explicitly exclude kernel code from userspace checks 2022-05-10 10:20:55 -07:00
libefi Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
libicp Introduce BLAKE3 checksums as an OpenZFS feature 2022-06-08 15:55:57 -07:00
libnvpair Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
libshare Fix unsafe string operations 2022-09-27 16:47:24 -07:00
libspl Reduce false positives from Static Analyzers 2022-09-30 15:30:12 -07:00
libtpool Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
libunicode cppcheck: explicitly exclude kernel code from userspace checks 2022-05-10 10:20:55 -07:00
libuutil Cleanup: Remove unused uu_pname code 2022-09-19 17:33:52 -07:00
libzfs Handle possible null pointers from malloc/strdup/strndup() 2022-10-06 17:18:40 -07:00
libzfs_core Implement a new type of zfs receive: corrective receive (-c) 2022-07-28 15:52:46 -07:00
libzfsbootenv Fix unchecked return values and unused return values 2022-09-23 16:52:03 -07:00
libzpool Fix memory leak found by GCC static analyzer 2022-10-03 13:41:58 -07:00
libzstd cppcheck: explicitly exclude kernel code from userspace checks 2022-05-10 10:20:55 -07:00
libzutil Handle possible null pointers from malloc/strdup/strndup() 2022-10-06 17:18:40 -07:00
Makefile.am autoconf: use include directives instead of recursing down lib 2022-05-10 10:18:11 -07:00