Bootstrap_read_devfs does not remove the devices it creates during the
course of its execution which might be considered as a resource
leak. Remedy that by adding the code to remove those devices upon
function completion.

Signed-off-by: Andrey Smirnov <andrew.smir...@gmail.com>
---
 lib/bootstrap/devfs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/bootstrap/devfs.c b/lib/bootstrap/devfs.c
index 359981e..d7b5185 100644
--- a/lib/bootstrap/devfs.c
+++ b/lib/bootstrap/devfs.c
@@ -99,7 +99,7 @@ void* bootstrap_read_devfs(char *devname, bool use_bb, int 
offset,
                        bootstrap_err(
                                "%s: failed to add bad block aware partition 
(%d)\n",
                                devname, ret);
-                       goto exit;
+                       goto delete_devfs_partition;
                }

                partname = "bbx";
@@ -138,6 +138,15 @@ free_memory:
        free(header);
        if (!result)
                free(to);
+
+       if (use_bb) {
+               dev_remove_bb_dev(partname);
+               partname = "x";
+       }
+
+delete_devfs_partition:
+       devfs_del_partition(partname);
+
 exit:
        return result;
 }
--
2.1.4

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to