mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH v2 7/8] bootstrap_read_devfs(): Remove all partitions upon function completion
Date: Sun,  3 May 2015 14:55:25 -0700	[thread overview]
Message-ID: <1430690125-2257-4-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1430690125-2257-1-git-send-email-andrew.smirnov@gmail.com>

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.smirnov@gmail.com>
---

Changes since v1:

 - Fix a compile time error that snuck in during the time the diff was
   being split into multiple patches

 lib/bootstrap/devfs.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/bootstrap/devfs.c b/lib/bootstrap/devfs.c
index df4840e..e9bd2bb 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,14 @@ free_memory:
 	free(header);
 	if (!result)
 		free(to);
-exit:
+
+	if (use_bb) {
+		dev_remove_bb_dev(partname);
+		partname = "x";
+	}
+
+delete_devfs_partition:
+	devfs_del_partition(partname);
+
 	return result;
 }
--
2.1.4

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

  parent reply	other threads:[~2015-05-03 21:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-03 21:55 [PATCH v2 1/8] imx-image: Correctly fill image size in prepended header Andrey Smirnov
2015-05-03 21:55 ` [PATCH v2 3/8] bootstrap_read_devfs(): Check for errors from devfs_add_partition() Andrey Smirnov
2015-05-03 21:55 ` [PATCH v2 5/8] bootstrap_read_devfs(): Fix potential memory leak Andrey Smirnov
2015-05-03 21:55 ` Andrey Smirnov [this message]
2015-05-03 22:05 ` [PATCH v2 1/8] imx-image: Correctly fill image size in prepended header Marc Kleine-Budde
     [not found]   ` <CAHQ1cqEoL1PD4Cg7G52YvosXmsmcg1jckGL9-65_J-=qHc3XvA@mail.gmail.com>
2015-05-03 22:34     ` Marc Kleine-Budde
2015-05-04  7:41 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430690125-2257-4-git-send-email-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox