All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ieee1275: ofdisk dangling pointer
@ 2015-10-26 21:43 Eric Snowberg
  2015-10-26 21:43 ` [PATCH 2/3] ieee1275: ofdisk memory leak Eric Snowberg
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Eric Snowberg @ 2015-10-26 21:43 UTC (permalink / raw)
  To: grub-devel, eric.snowberg; +Cc: Eric Snowberg

Within commit: 87ec3b7fa9061f470616ed927fc140e995831c00 -
"Don't continue to query block-size if disk doesn't have it.”
a dangling pointer was introduced.

Fix dangling pointer issue in grub_ofdisk_open where devpath is freed
and then used again within the call to grub_ofdisk_get_block_size. This
solves many memory corruption issues we were seeing.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 grub-core/disk/ieee1275/ofdisk.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
index 331769b..4a5632c 100644
--- a/grub-core/disk/ieee1275/ofdisk.c
+++ b/grub-core/disk/ieee1275/ofdisk.c
@@ -422,10 +422,11 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
     op = ofdisk_hash_find (devpath);
     if (!op)
       op = ofdisk_hash_add (devpath, NULL);
-    else
-      grub_free (devpath);
     if (!op)
-      return grub_errno;
+      {
+        grub_free (devpath);
+        return grub_errno;
+      }
     disk->id = (unsigned long) op;
     disk->data = op->open_path;
 
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-11-10 17:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 21:43 [PATCH 1/3] ieee1275: ofdisk dangling pointer Eric Snowberg
2015-10-26 21:43 ` [PATCH 2/3] ieee1275: ofdisk memory leak Eric Snowberg
2015-10-26 22:03   ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-10-26 21:43 ` [PATCH 3/3] ieee1275: ofdisk - don't continue to query block-size after we have it Eric Snowberg
2015-10-26 22:02   ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-11-10  8:01     ` Andrei Borzenkov
2015-11-10 17:45       ` Eric Snowberg
2015-10-26 22:03 ` [PATCH 1/3] ieee1275: ofdisk dangling pointer Vladimir 'φ-coder/phcoder' Serbinenko
2015-10-29 14:48 ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.