From d804ae2a602c9b192ee6d709af0cb7b4b8c3cd74 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 29 Jan 2018 20:43:42 +0100 Subject: usb: gadget: fastboot: allow data.image to be const 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 --- drivers/usb/gadget/f_fastboot.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers') 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)); -- cgit v1.2.3