2
1

0048-disk-ieee1275-ofdisk-Call-grub_ieee1275_close-when-g.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From 2dcfad49316cc757138a8c69f6b44ee1a240aa3d Mon Sep 17 00:00:00 2001
  2. From: Alec Brown <alec.r.brown@oracle.com>
  3. Date: Wed, 22 Jan 2025 02:55:12 +0000
  4. Subject: [PATCH] disk/ieee1275/ofdisk: Call grub_ieee1275_close() when
  5. grub_malloc() fails
  6. In the dev_iterate() function a handle is opened but isn't closed when
  7. grub_malloc() returns NULL. We should fix this by closing it on error.
  8. Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
  9. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  10. Upstream: fbaddcca541805c333f0fc792b82772594e73753
  11. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  12. ---
  13. grub-core/disk/ieee1275/ofdisk.c | 5 ++++-
  14. 1 file changed, 4 insertions(+), 1 deletion(-)
  15. diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
  16. index 4c5b89cbc..dbc0f1aba 100644
  17. --- a/grub-core/disk/ieee1275/ofdisk.c
  18. +++ b/grub-core/disk/ieee1275/ofdisk.c
  19. @@ -267,7 +267,10 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
  20. buf = grub_malloc (sz);
  21. if (!buf)
  22. - return;
  23. + {
  24. + grub_ieee1275_close (ihandle);
  25. + return;
  26. + }
  27. bufptr = grub_stpcpy (buf, alias->path);
  28. for (i = 0; i < args.nentries; i++)
  29. --
  30. 2.50.1