public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/3] dfu: Fix data abort in dfu_free_entities()
Date: Tue, 24 Jul 2018 23:14:30 +0200	[thread overview]
Message-ID: <20180724231430.0119486c@jawa> (raw)
In-Reply-To: <CAKaJLVvVc+CLfB=qsHJaOEbjrfTc1ZeO_UkDYL5BRMOTRu=RDQ@mail.gmail.com>

Hi Sam,

> On Fri, Jul 13, 2018 at 4:35 PM, Sam Protsenko
> <semen.protsenko@linaro.org> wrote:
> > Commit 5d8fae79163e ("dfu: avoid memory leak") brings a regression
> > which described below. This patch is effectively reverting that
> > commit, adding corresponding comment to avoid such regressions in
> > future.
> >
> > In case of error in dfu_config_entities(), it frees "dfu" array,
> > which leads to "data abort" in dfu_free_entities(), which tries to
> > free the same array (and even tries to access it from linked list
> > first). The issue occurs e.g. when partition table on device does
> > not match $dfu_alt_info layout:
> >  
> >     => dfu 0 mmc 1  
> >     Couldn't find part #2 on mmc device #1
> >     DFU entities configuration failed!
> >     data abort
> >
> > To fix this issue, do not free "dfu" array in
> > dfu_config_entities(). It will be freed later in
> > dfu_free_entities().
> >
> > Tested on BeagleBone Black (where this regression was originally
> > found).
> >
> > Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> > ---
> > Changes in v2:
> >   - Improve commit message by mentioning regression commit
> >  
> 
> Hi Lukasz,
> 
> Can you please review and merge this whole series?

This has been already included:

http://git.denx.de/?p=u-boot/u-boot-dfu.git;a=shortlog;h=refs/heads/master

Marek has fetch this tree and will send PR soon.

> 
> Thanks!
> 
> >  drivers/dfu/dfu.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> > index e7c91193b9..a3c09334b7 100644
> > --- a/drivers/dfu/dfu.c
> > +++ b/drivers/dfu/dfu.c
> > @@ -462,7 +462,7 @@ int dfu_config_entities(char *env, char
> > *interface, char *devstr) ret = dfu_fill_entity(&dfu[i], s,
> > alt_num_cnt, interface, devstr);
> >                 if (ret) {
> > -                       free(dfu);
> > +                       /* We will free "dfu" in
> > dfu_free_entities() */ return -1;
> >                 }
> >
> > --
> > 2.18.0
> >  




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180724/64197372/attachment.sig>

      reply	other threads:[~2018-07-24 21:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 13:35 [U-Boot] [PATCH v2 1/3] dfu: Fix data abort in dfu_free_entities() Sam Protsenko
2018-07-13 13:35 ` [U-Boot] [PATCH v2 2/3] dfu: Fix memory leak in dfu_init_env_entities() Sam Protsenko
2018-07-13 13:35 ` [U-Boot] [PATCH v2 3/3] dfu: Provide more verbose error message Sam Protsenko
2018-07-24 16:41 ` [U-Boot] [PATCH v2 1/3] dfu: Fix data abort in dfu_free_entities() Sam Protsenko
2018-07-24 21:14   ` Lukasz Majewski [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=20180724231430.0119486c@jawa \
    --to=lukma@denx.de \
    --cc=u-boot@lists.denx.de \
    /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