From: Eugene Korenevsky <ekorenevsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Matt Fleming
<matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>,
Linn Crosetto <linn-ZPxbGqLxI0U@public.gmane.org>,
"H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>,
Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH v2] EFI loader: remove redundant code
Date: Wed, 2 Nov 2016 16:56:03 +0300 [thread overview]
Message-ID: <20161102135603.GA8090@vnote> (raw)
In-Reply-To: <CAKv+Gu8xkxPSkA+3Sqo-kcL=b6ex6MNQ7DrDV_sqcQrfmqkvCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> > *e820ext is always NULL in 'alloc_e820ext()' (see the code of 'exit_boot()').
> > Without loss of generality we can replace freeing with returning
> > EFI_INVALID_PARAMETER. So if the caller would ever incorrectly pass non-NULL
> > *e820ext, he will obtain a returned error code.
> >
>
> What exactly are you trying to fix here? Adding new artificial failure
> modes is hardly worth it when all you are doing is cleaning up code
> that by itself is correct to begin with, but is simply never called.
This code (free_pool, assignments) is dead whether it is correct or
not. So it is to be removed.
The check gives some assurance that memory is not leaked if the calling
code is changed.
> > @@ -956,11 +956,8 @@ static efi_status_t alloc_e820ext(u32 nr_desc, struct setup_data **e820ext,
> > size = sizeof(struct setup_data) +
> > sizeof(struct e820entry) * nr_desc;
> >
> > - if (*e820ext) {
> > - efi_call_early(free_pool, *e820ext);
> > - *e820ext = NULL;
> > - *e820ext_size = 0;
> > - }
> > + if (*e820ext)
> > + return EFI_INVALID_PARAMETER;
> >
> > status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
> > size, (void **)e820ext);
> > --
--
Eugene
WARNING: multiple messages have this Message-ID (diff)
From: Eugene Korenevsky <ekorenevsky@gmail.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
Matt Fleming <matt@codeblueprint.co.uk>,
Linn Crosetto <linn@hpe.com>, "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH v2] EFI loader: remove redundant code
Date: Wed, 2 Nov 2016 16:56:03 +0300 [thread overview]
Message-ID: <20161102135603.GA8090@vnote> (raw)
In-Reply-To: <CAKv+Gu8xkxPSkA+3Sqo-kcL=b6ex6MNQ7DrDV_sqcQrfmqkvCw@mail.gmail.com>
> > *e820ext is always NULL in 'alloc_e820ext()' (see the code of 'exit_boot()').
> > Without loss of generality we can replace freeing with returning
> > EFI_INVALID_PARAMETER. So if the caller would ever incorrectly pass non-NULL
> > *e820ext, he will obtain a returned error code.
> >
>
> What exactly are you trying to fix here? Adding new artificial failure
> modes is hardly worth it when all you are doing is cleaning up code
> that by itself is correct to begin with, but is simply never called.
This code (free_pool, assignments) is dead whether it is correct or
not. So it is to be removed.
The check gives some assurance that memory is not leaked if the calling
code is changed.
> > @@ -956,11 +956,8 @@ static efi_status_t alloc_e820ext(u32 nr_desc, struct setup_data **e820ext,
> > size = sizeof(struct setup_data) +
> > sizeof(struct e820entry) * nr_desc;
> >
> > - if (*e820ext) {
> > - efi_call_early(free_pool, *e820ext);
> > - *e820ext = NULL;
> > - *e820ext_size = 0;
> > - }
> > + if (*e820ext)
> > + return EFI_INVALID_PARAMETER;
> >
> > status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
> > size, (void **)e820ext);
> > --
--
Eugene
next prev parent reply other threads:[~2016-11-02 13:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-02 4:18 [PATCH v2] EFI loader: remove redundant code Eugene Korenevsky
2016-11-02 4:18 ` Eugene Korenevsky
2016-11-02 9:25 ` Ard Biesheuvel
[not found] ` <CAKv+Gu8xkxPSkA+3Sqo-kcL=b6ex6MNQ7DrDV_sqcQrfmqkvCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-02 13:56 ` Eugene Korenevsky [this message]
2016-11-02 13:56 ` Eugene Korenevsky
2016-11-02 13:57 ` Ard Biesheuvel
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=20161102135603.GA8090@vnote \
--to=ekorenevsky-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
--cc=linn-ZPxbGqLxI0U@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org \
--cc=mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.