loader/xnu: Fix memory leak

In grub_xnu_load_kext_from_dir(), when the call to grub_device_open()
failed, it simply cleaned up previously allocated memory and returned
GRUB_ERR_NONE. However, it neglected to free ctx->newdirname which is
allocated before the call to grub_device_open().

Fixes: CID 473859

Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Lidong Chen 2025-03-27 17:56:35 +00:00 committed by Daniel Kiper
parent f94d257e8c
commit 6b64f297e5

View File

@ -1258,6 +1258,7 @@ grub_xnu_load_kext_from_dir (char *dirname, const char *osbundlerequired,
grub_device_close (dev);
}
grub_free (device_name);
grub_free (ctx.newdirname);
return GRUB_ERR_NONE;
}