Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1501876
| Path | csiph.com!fu-berlin.de!bofh.it!news.nic.it!robomod |
|---|---|
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] UBI: Fix crash in try_recover_peb() |
| Date | Mon, 17 Oct 2016 13:10:01 +0200 |
| Message-ID | <stdXP-2H4-15@gated-at.bofh.it> (permalink) |
| References | <srPbb-4G0-11@gated-at.bofh.it> <srPbc-4G0-35@gated-at.bofh.it> <stb9E-Tq-49@gated-at.bofh.it> |
| X-Original-To | Geert Uytterhoeven <geert@linux-m68k.org> |
| X-Mailer | Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8BIT |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 66 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Richard Weinberger <richard@nod.at>, Brian Norris <computersforpeace@gmail.com>, Artem Bityutskiy <dedekind1@gmail.com>, David Woodhouse <dwmw2@infradead.org>, MTD Maling List <linux-mtd@lists.infradead.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org> |
| X-Original-Date | Mon, 17 Oct 2016 13:02:18 +0200 |
| X-Original-Message-ID | <20161017130218.1d2e19e3@bbrezillon> |
| X-Original-References | <1476367536-24782-1-git-send-email-geert@linux-m68k.org> <20161013162458.0219177b@bbrezillon> <CAMuHMdVJJxN2bU6JVsia9uDMonczqMw3SiAu-eygnHVLUqcqMg@mail.gmail.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1501876 |
Show key headers only | View raw
On Mon, 17 Oct 2016 10:00:25 +0200
Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Boris,
>
> On Thu, Oct 13, 2016 at 4:24 PM, Boris Brezillon
> <boris.brezillon@free-electrons.com> wrote:
> > On Thu, 13 Oct 2016 16:05:36 +0200
> > Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> >
> >> drivers/mtd/ubi/eba.c: In function ‘try_recover_peb’:
> >> drivers/mtd/ubi/eba.c:744: warning: ‘vid_hdr’ is used uninitialized in this function
> >>
> >> The pointer vid_hdr is indeed not initialized, leading to a crash when
> >> it is dereferenced.
> >>
> >> Fix this by obtaining the pointer from the VID buffer, like is done
> >> everywhere else.
> >
> > Indeed, I don't know how I missed that one :-/.
> >
> >>
> >> Fixes: 3291b52f9ff0acc8 ("UBI: introduce the VID buffer concept")
> >> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> >
> > One minor comment below, otherwise
> >
> > Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
>
> Thanks!
>
> >> ---
> >> Completely untested. And I know nothing about UBI ;-)
> >> ---
> >> drivers/mtd/ubi/eba.c | 1 +
> >> 1 file changed, 1 insertion(+)
> >>
> >> diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
> >> index 95c4048a371e87b6..388e46be6ad92805 100644
> >> --- a/drivers/mtd/ubi/eba.c
> >> +++ b/drivers/mtd/ubi/eba.c
> >> @@ -741,6 +741,7 @@ static int try_recover_peb(struct ubi_volume *vol, int pnum, int lnum,
> >> goto out_put;
> >> }
> >>
> >> + vid_hdr = ubi_get_vid_hdr(vidb);
> >
> > Can you move this assignment at variable declaration time?
>
> I can do that. However, that moves the call to ubi_get_vid_hdr() _before_
> the call to ubi_io_read_vid_hdr().
>
> While that would still work (ubi_get_vid_hdr() would just return a pointer to
> the not-yet-read data), I think it's better to not move it, to prevent people
> from accidentally trying to use it before the data has been read.
Well, maybe. I just thought it would be safer to assign it as early as
possible to avoid another 'uninitialized var' bug if move code around
again (which will happen soon ;-)).
Anyway, it's not that important, I'll let Richard take the version
he prefers.
Thanks again for the fix.
Boris
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] UBI: Fix crash in try_recover_peb() Geert Uytterhoeven <geert@linux-m68k.org> - 2016-10-13 16:30 +0200
Re: [PATCH] UBI: Fix crash in try_recover_peb() Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-10-13 16:30 +0200
Re: [PATCH] UBI: Fix crash in try_recover_peb() Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-10-14 12:50 +0200
Re: [PATCH] UBI: Fix crash in try_recover_peb() Geert Uytterhoeven <geert@linux-m68k.org> - 2016-10-17 10:10 +0200
Re: [PATCH] UBI: Fix crash in try_recover_peb() Geert Uytterhoeven <geert@linux-m68k.org> - 2016-10-17 10:10 +0200
Re: [PATCH] UBI: Fix crash in try_recover_peb() Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-10-17 13:10 +0200
Re: [PATCH] UBI: Fix crash in try_recover_peb() Geert Uytterhoeven <geert@linux-m68k.org> - 2016-10-17 13:20 +0200
csiph-web