disk: Check if returned pointer for allocated memory is NULL
authorAlec Brown <alec.r.brown@oracle.com>
Wed, 22 Jan 2025 02:55:11 +0000 (02:55 +0000)
committerFelix Zielcke <fzielcke@z-51.de>
Wed, 11 Jun 2025 15:42:34 +0000 (17:42 +0200)
commit17117015cc17011d51f2da551337cf460f90c31a
treeeadad1cd202a342b30192745e5357c1dba9fc5b6
parent40f6bb71d2358cd5bd29258ce6557bfa6984331d
disk: Check if returned pointer for allocated memory is NULL

When using grub_malloc(), grub_zalloc() or grub_calloc(), these functions can
fail if we are out of memory. After allocating memory we should check if these
functions returned NULL and handle this error if they did.

On the occasion make a NULL check in ATA code more obvious.

Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name disk-Check-if-returned-pointer-for-allocated-memory-is-NU.patch
grub-core/disk/ata.c
grub-core/disk/ieee1275/obdisk.c
grub-core/disk/ldm.c
grub-core/disk/lvm.c
grub-core/disk/memdisk.c