]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
zfs: Fix malloc() success check
authormwleeds@mailtundra.com <mwleeds@mailtundra.com>
Sun, 7 Apr 2024 01:47:25 +0000 (18:47 -0700)
committerTom Rini <trini@konsulko.com>
Wed, 17 Apr 2024 16:08:48 +0000 (10:08 -0600)
This code was hitting the error code path whenever malloc() succeeded
rather than when it failed, so presumably this part of the code hasn't
been tested. I had to apply this fix (and others) to get U-Boot to boot
from ZFS on an Nvidia Jetson TX2 NX SoM (an aarch64 computer).

Signed-off-by: Phaedrus Leeds <mwleeds@mailtundra.com>
fs/zfs/zfs.c

index 1fec96cd5ce5a67171d1c66e1b0974870704571d..14779dee32d834de2d026b563f52a75448173a4c 100644 (file)
@@ -655,7 +655,7 @@ dmu_read(dnode_end_t *dn, uint64_t blkid, void **buf,
                                                                                        dn->endian)
                                << SPA_MINBLOCKSHIFT;
                        *buf = malloc(size);
-                       if (*buf) {
+                       if (!*buf) {
                                err = ZFS_ERR_OUT_OF_MEMORY;
                                break;
                        }