bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] pci-arbiter: Fix memory bugs


From: Joan Lledó
Subject: [PATCH] pci-arbiter: Fix memory bugs
Date: Sun, 24 Nov 2019 20:47:45 +0100 (CET)

From: Joan Lledó <jlledom@member.fsf.org>

* pci-arbiter/pcifs.c:
        * init_file_system: Remove unnecessary free()
        * create_fs_tree:
          Fix a boundary overrun where no devices are found.
---
 pci-arbiter/pcifs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pci-arbiter/pcifs.c b/pci-arbiter/pcifs.c
index aaee7f0b..d19fc618 100644
--- a/pci-arbiter/pcifs.c
+++ b/pci-arbiter/pcifs.c
@@ -115,7 +115,6 @@ init_file_system (file_t underlying_node, struct pcifs * fs)
   fs->entries = calloc (1, sizeof (struct pcifs_dirent));
   if (!fs->entries)
     {
-      free (fs->entries);
       return ENOMEM;
     }
 
@@ -189,6 +188,12 @@ create_fs_tree (struct pcifs * fs)
 
   pci_iterator_destroy(iter);
 
+  if (nentries == 1)
+    {
+      /* No devices found, no need to continue */
+      return 0;
+    }
+
   list = realloc (fs->entries, nentries * sizeof (struct pcifs_dirent));
   if (!list)
     return ENOMEM;
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]