[PATCH 5/6] usb: gadget: fastboot: allow data.image to be const

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

 



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@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux