From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 5/6] usb: gadget: fastboot: allow data.image to be const
Date: Tue, 30 Jan 2018 09:46:56 +0100 [thread overview]
Message-ID: <20180130084657.31943-6-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20180130084657.31943-1-s.hauer@pengutronix.de>
Do not directly store the dynamically allocated memory in data.image
as we want to make that pointer const and then no longer can call
free() on it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/gadget/f_fastboot.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 2ba5977239..87a43cc60e 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -935,6 +935,7 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd
}
if (IS_ENABLED(CONFIG_BAREBOX_UPDATE) && filetype_is_barebox_image(filetype)) {
+ void *image;
struct bbu_data data = {
.devicefile = filename,
.imagefile = FASTBOOT_TMPFILE,
@@ -946,15 +947,17 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd
fastboot_tx_print(f_fb, "INFOThis is a barebox image...");
- data.image = read_file(data.imagefile, &data.len);
- if (!data.image) {
+ image = read_file(data.imagefile, &data.len);
+ if (!image) {
fastboot_tx_print(f_fb, "FAILreading barebox");
return;
}
+ data.image = image;
+
ret = barebox_update(&data);
- free(data.image);
+ free(image);
if (ret) {
fastboot_tx_print(f_fb, "FAILupdate barebox: %s", strerror(-ret));
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-01-30 8:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-30 8:46 [PATCH 0/6] bbu: Make image pointer const Sascha Hauer
2018-01-30 8:46 ` [PATCH 1/6] bbu: imx-bbu-internal: Do not modify image Sascha Hauer
2018-01-30 8:46 ` [PATCH 2/6] bbu: imx-bbu-internal: make pointers to image const Sascha Hauer
2018-01-30 8:46 ` [PATCH 3/6] bbu: command: create temporary variable holding the pointer to the image Sascha Hauer
2018-01-30 8:46 ` [PATCH 4/6] bbu: Make pointer to image const Sascha Hauer
2018-01-30 8:46 ` Sascha Hauer [this message]
2018-01-30 8:46 ` [PATCH 6/6] ARM: am33xx: bbu: Make pointers " 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=20180130084657.31943-6-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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