mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 06:49:35 +00:00
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>
This commit is contained in:
1 parent
d8151f9833
commit
33bd6b5ac5
5 files changed
+30
-2
No files matched your search
@@ -423,6 +423,12 @@ canonicalise_disk (const char *devname)
|
||||
}
|
||||
|
||||
real_canon = grub_malloc (real_unit_str_len);
|
||||
if (real_canon == NULL)
|
||||
{
|
||||
grub_free (parent);
|
||||
grub_print_error ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
grub_snprintf (real_canon, real_unit_str_len, "%s/disk@%s",
|
||||
op->name, real_unit_address);
|
||||
|
||||
Reference in new issue
Block a user