public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* ubinize corrections
@ 2008-11-02 19:23 J. Scott Merritt
  2008-11-03  8:41 ` Adrian Hunter
  0 siblings, 1 reply; 4+ messages in thread
From: J. Scott Merritt @ 2008-11-02 19:23 UTC (permalink / raw)
  To: linux-mtd

Dear list,

I believe that I have stumbled upon two problems with the latest version
of ubinize.c in mtd-utils - one serious, and one not so serious.

- First, the easy one: At line 457, I believe that we should be printing
args.subpage_size rather than ui.min_io_size.

- More seriously, I believe that the "flags" field in the ubigen_vol_info
structures is not being properly initialized.  Line 494 allocates memory
for these structures with malloc, so they are not cleared to zero.  The
read_section function updates the flag field if the AUTO-RESIZE flag is
specified, but does not otherwise initialize or clear it.

I reckon the latter problem could be repaired either with calloc, or by
modifying read_section to more directly set/clear the flag.

Thanks, Scott.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ubinize corrections
  2008-11-02 19:23 ubinize corrections J. Scott Merritt
@ 2008-11-03  8:41 ` Adrian Hunter
  2008-11-03 16:49   ` J. Scott Merritt
  2008-11-06  7:13   ` Artem Bityutskiy
  0 siblings, 2 replies; 4+ messages in thread
From: Adrian Hunter @ 2008-11-03  8:41 UTC (permalink / raw)
  To: J. Scott Merritt; +Cc: linux-mtd

J. Scott Merritt wrote:
> Dear list,
> 
> I believe that I have stumbled upon two problems with the latest version
> of ubinize.c in mtd-utils - one serious, and one not so serious.
> 
> - First, the easy one: At line 457, I believe that we should be printing
> args.subpage_size rather than ui.min_io_size.
> 
> - More seriously, I believe that the "flags" field in the ubigen_vol_info
> structures is not being properly initialized.  Line 494 allocates memory
> for these structures with malloc, so they are not cleared to zero.  The
> read_section function updates the flag field if the AUTO-RESIZE flag is
> specified, but does not otherwise initialize or clear it.
> 
> I reckon the latter problem could be repaired either with calloc, or by
> modifying read_section to more directly set/clear the flag.
> 
> Thanks, Scott.

I agree.  Here's the patch:


From: Adrian Hunter <ext-adrian.hunter@nokia.com>
Date: Mon, 3 Nov 2008 10:36:32 +0200
Subject: [PATCH] ubinize: correct subpage_size print and initialise vol_info to zero

Reported-by: "J. Scott Merritt" <merrij3@rpi.edu>
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
---
 ubi-utils/new-utils/src/ubinize.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ubi-utils/new-utils/src/ubinize.c b/ubi-utils/new-utils/src/ubinize.c
index ebd5aa0..4f3e8a1 100644
--- a/ubi-utils/new-utils/src/ubinize.c
+++ b/ubi-utils/new-utils/src/ubinize.c
@@ -454,7 +454,7 @@ int main(int argc, char * const argv[])
        verbose(args.verbose, "LEB size:      %d", ui.leb_size);
        verbose(args.verbose, "PEB size:      %d", ui.peb_size);
        verbose(args.verbose, "min. I/O size: %d", ui.min_io_size);
-       verbose(args.verbose, "sub-page size: %d", ui.min_io_size);
+       verbose(args.verbose, "sub-page size: %d", args.subpage_size);
        verbose(args.verbose, "VID offset:    %d", ui.vid_hdr_offs);
        verbose(args.verbose, "data offset:   %d", ui.data_offs);
 
@@ -491,7 +491,7 @@ int main(int argc, char * const argv[])
                goto out_dict;
        }
 
-       vi = malloc(sizeof(struct ubigen_vol_info) * sects);
+       vi = calloc(sizeof(struct ubigen_vol_info), sects);
        if (!vi) {
                errmsg("cannot allocate memory");
                goto out_dict;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: ubinize corrections
  2008-11-03  8:41 ` Adrian Hunter
@ 2008-11-03 16:49   ` J. Scott Merritt
  2008-11-06  7:13   ` Artem Bityutskiy
  1 sibling, 0 replies; 4+ messages in thread
From: J. Scott Merritt @ 2008-11-03 16:49 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: linux-mtd


> From: Adrian Hunter <ext-adrian.hunter@nokia.com>
> Date: Mon, 3 Nov 2008 10:36:32 +0200
> Subject: [PATCH] ubinize: correct subpage_size print and initialise vol_info to zero
> 
> Reported-by: "J. Scott Merritt" <merrij3@rpi.edu>
> Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
> ---

Adrian,

Thank you.  Not sure of the protocol/sequence, but you are welcome
to add my Acked-by: if helpful ...

Regards, Scott.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ubinize corrections
  2008-11-03  8:41 ` Adrian Hunter
  2008-11-03 16:49   ` J. Scott Merritt
@ 2008-11-06  7:13   ` Artem Bityutskiy
  1 sibling, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2008-11-06  7:13 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: linux-mtd, J. Scott Merritt

On Mon, 2008-11-03 at 10:41 +0200, Adrian Hunter wrote:
> J. Scott Merritt wrote:
> > Dear list,
> > 
> > I believe that I have stumbled upon two problems with the latest version
> > of ubinize.c in mtd-utils - one serious, and one not so serious.
> > 
> > - First, the easy one: At line 457, I believe that we should be printing
> > args.subpage_size rather than ui.min_io_size.
> > 
> > - More seriously, I believe that the "flags" field in the ubigen_vol_info
> > structures is not being properly initialized.  Line 494 allocates memory
> > for these structures with malloc, so they are not cleared to zero.  The
> > read_section function updates the flag field if the AUTO-RESIZE flag is
> > specified, but does not otherwise initialize or clear it.
> > 
> > I reckon the latter problem could be repaired either with calloc, or by
> > modifying read_section to more directly set/clear the flag.
> > 
> > Thanks, Scott.
> 
> I agree.  Here's the patch:

Pushed, thanks for the report and the patch.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-11-06  7:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-02 19:23 ubinize corrections J. Scott Merritt
2008-11-03  8:41 ` Adrian Hunter
2008-11-03 16:49   ` J. Scott Merritt
2008-11-06  7:13   ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox