0071-zfsinfo-Correct-a-check-for-error-allocating-memory.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From 7aab03418ec6a9b991aa44416cb2585aff4e7972 Mon Sep 17 00:00:00 2001
  2. From: Darren Kenny <darren.kenny@oracle.com>
  3. Date: Thu, 26 Nov 2020 10:56:45 +0000
  4. Subject: [PATCH] zfsinfo: Correct a check for error allocating memory
  5. While arguably the check for grub_errno is correct, we should really be
  6. checking the return value from the function since it is always possible
  7. that grub_errno was set elsewhere, making this code behave incorrectly.
  8. Fixes: CID 73668
  9. Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
  10. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  11. Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
  12. ---
  13. grub-core/fs/zfs/zfsinfo.c | 4 ++--
  14. 1 file changed, 2 insertions(+), 2 deletions(-)
  15. diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c
  16. index c8a28ac..bf29180 100644
  17. --- a/grub-core/fs/zfs/zfsinfo.c
  18. +++ b/grub-core/fs/zfs/zfsinfo.c
  19. @@ -358,8 +358,8 @@ grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc,
  20. return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
  21. devname = grub_file_get_device_name (args[0]);
  22. - if (grub_errno)
  23. - return grub_errno;
  24. + if (devname == NULL)
  25. + return GRUB_ERR_OUT_OF_MEMORY;
  26. dev = grub_device_open (devname);
  27. grub_free (devname);
  28. --
  29. 2.14.2