Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1345663
| From | Minfei Huang <mhuang@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] kexec: Make a pair of map/unmap reserved pages in error path |
| Date | 2016-02-29 12:10 +0100 |
| Message-ID | <r7tSb-2et-41@gated-at.bofh.it> (permalink) |
| References | <r64Cv-4Cd-11@gated-at.bofh.it> <r6BoK-3aU-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 02/26/16 at 04:56pm, Andrew Morton wrote:
> On Thu, 25 Feb 2016 22:02:40 +0800 Minfei Huang <mhuang@redhat.com> wrote:
>
> > From: Minfei Huang <mnfhuang@gmail.com>
> >
> > For some arch, kexec shall map the reserved pages, then use them, when
> > we try to start the kdump service.
> >
> > kexec may return directly, without unmaping the reserved pages, if it
> > fails during starting service. To fix it, we make a pair of map/unmap
> > reserved pages both in generic path and error path.
>
> This patch both refactors the code AND fixes the bug. It is a
> decent-looking refactoring, but mixing the two together makes it *much*
> harder to review the bugfix. These two steps should be separated
> please, with the bugfix patch coming first.
I will bisect this patch to make it more simple to be reviewed.
>
> > --- a/kernel/kexec.c
> > +++ b/kernel/kexec.c
> > @@ -103,6 +103,68 @@ out_free_image:
> > return ret;
> > }
> >
> > +static int do_kexec_load(unsigned long entry, unsigned long nr_segments,
> > + struct kexec_segment __user *segments, unsigned long flags)
> > +{
> > + struct kimage **dest_image, *image;
> > + unsigned long i;
> > + int ret;
> > +
> > + if (flags & KEXEC_ON_CRASH)
> > + dest_image = &kexec_crash_image;
> > + else
> > + dest_image = &kexec_image;
> > +
> > + if (nr_segments == 0) {
> > + /* Uninstall image */
> > + kimage_free(xchg(dest_image, NULL));
> > + return 0;
> > + }
> > + if (flags & KEXEC_ON_CRASH) {
> > + /*
> > + * Loading another kernel to switch to if this one
> > + * crashes. Free any current crash dump kernel before
> > + * we corrupt it.
> > + */
> > + kimage_free(xchg(&kexec_crash_image, NULL));
> > + }
> > +
> > + ret = kimage_alloc_init(&image, entry, nr_segments, segments, flags);
> > + if (ret)
> > + return ret;
>
> This is a bug, isn't it? Missed kimage_free().
The variable image is NULL, if kimage_alloc_init returns with error. And
kimage_alloc_init will do the cleanup before returning. So it's fine
without calling kimage_free.
Thanks
Minfei
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] kexec: Make a pair of map/unmap reserved pages in error path Minfei Huang <mhuang@redhat.com> - 2016-02-25 15:00 +0100
Re: [PATCH] kexec: Make a pair of map/unmap reserved pages in error path Andrew Morton <akpm@linux-foundation.org> - 2016-02-27 02:00 +0100
Re: [PATCH] kexec: Make a pair of map/unmap reserved pages in error path Minfei Huang <mhuang@redhat.com> - 2016-02-29 12:10 +0100
csiph-web