From 1fc860bb76bb29945829a1e2fb37e57a7a1c24e8 Mon Sep 17 00:00:00 2001 From: Darren Kenny Date: Fri, 27 Nov 2020 15:41:44 +0000 Subject: [PATCH] commands/probe: Fix a resource leak when probing disks Every other return statement in this code is calling grub_device_close() to clean up dev before returning. This one should do that too. Fixes: CID 292443 Signed-off-by: Darren Kenny Reviewed-by: Daniel Kiper --- grub-core/commands/probe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c index 573bdf603..e53b61178 100644 --- a/grub-core/commands/probe.c +++ b/grub-core/commands/probe.c @@ -111,7 +111,11 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args) grub_disk_t disk = grub_disk_open(dev->disk->name); if (!disk) - return grub_errno; + { + grub_device_close (dev); + return grub_errno; + } + if (grub_strcmp(dev->disk->partition->partmap->name, "gpt") == 0) { struct grub_gpt_partentry entry;