From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jules Maselbas <jmaselbas@kalray.eu>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 3/3] usb: gadget: dfu: Reset global variables on unbind
Date: Thu, 26 Mar 2020 07:09:57 +0100 [thread overview]
Message-ID: <20200326060957.GJ27288@pengutronix.de> (raw)
In-Reply-To: <20200324154647.17341-4-jmaselbas@kalray.eu>
On Tue, Mar 24, 2020 at 04:46:47PM +0100, Jules Maselbas wrote:
> Global variables must be reset to their default value before a new
> dfu_bind is done. Otherwise things wont work and are likely to cause
> a system crash due to a use after free: the global dfu_files was still
> pointing deallocated structure after unbind.
>
> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
> ---
> drivers/usb/gadget/dfu.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
> index 592586db1..5504f4933 100644
> --- a/drivers/usb/gadget/dfu.c
> +++ b/drivers/usb/gadget/dfu.c
> @@ -277,6 +277,15 @@ dfu_unbind(struct usb_configuration *c, struct usb_function *f)
> {
> struct f_dfu *dfu = func_to_dfu(f);
>
> + memset(&dfu_mtdinfo, 0, sizeof(dfu_mtdinfo));
> + dfu_files = NULL;
> + dfu_file_entry = NULL;
> + dfufd = -EINVAL;
> + dfudetach = 0;
> + dfu_written = 0;
> + dfu_erased = 0;
> + prog_erase = 0;
Ah, ok, here is the missing initialization ;)
Please swap the order of patches 2/3 and 3/3
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2020-03-26 6:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 15:46 [PATCH 0/3] usb: gadget: dfu: Fix timeout on erase when using big partition Jules Maselbas
2020-03-24 15:46 ` [PATCH 1/3] usb: gadget: dfu: Add manifestation phase Jules Maselbas
2020-03-24 15:46 ` [PATCH 2/3] usb: gadget: dfu: Progressive erase if file is a mtd Jules Maselbas
2020-03-26 6:03 ` Sascha Hauer
2020-03-26 9:08 ` Jules Maselbas
2020-03-24 15:46 ` [PATCH 3/3] usb: gadget: dfu: Reset global variables on unbind Jules Maselbas
2020-03-26 6:09 ` Sascha Hauer [this message]
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=20200326060957.GJ27288@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=jmaselbas@kalray.eu \
/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