]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
commands/probe: Fix a resource leak when probing disks
authorDarren Kenny <darren.kenny@oracle.com>
Fri, 27 Nov 2020 15:41:44 +0000 (15:41 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 2 Mar 2021 14:54:17 +0000 (15:54 +0100)
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 <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/probe.c

index 573bdf603b4e170029901b21cfd0b944b18f34d1..e53b611786df96ce4d179f1cffeaad50e0db0a5e 100644 (file)
@@ -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;