From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/7] JFFS2: Improve error checking
Date: Fri, 29 Apr 2011 15:18:22 +0200 [thread overview]
Message-ID: <m2sjt142n5.fsf@ohwell.denx.de> (raw)
In-Reply-To: <001f01cc0231$0c3896b0$6401a8c0@LENOVOE5CA6843> (Baidu Liu's message of "Sun, 24 Apr 2011 11:37:59 +0800")
Hi Baidu,
> Check the return value when we do malloc.
>
> Signed-off-by: Baidu Liu <liucai.lfn@gmail.com>
> ---
> fs/jffs2/jffs2_1pass.c | 12 ++++++++++--
> fs/jffs2/jffs2_nand_1pass.c | 5 ++++-
> 2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
> index be6ac78..b3d94af 100644
> --- a/fs/jffs2/jffs2_1pass.c
> +++ b/fs/jffs2/jffs2_1pass.c
> @@ -662,7 +662,8 @@ jffs2_free_cache(struct part_info *part)
> pL = (struct b_lists *)part->jffs2_priv;
> free_nodes(&pL->frag);
> free_nodes(&pL->dir);
> - free(pL->readbuf);
> + if(pL->readbuf)
> + free(pL->readbuf);
> free(pL);
> }
> }
This looks ok.
> @@ -1470,9 +1471,16 @@ jffs2_1pass_build_lists(struct part_info * part)
> /* lcd_off(); */
>
> /* if we are building a list we need to refresh the cache. */
> - jffs_init_1pass_list(part);
> + if(! jffs_init_1pass_list(part))
> + return 0;
> +
This is strange. We now check for an error of jffs2_init_1pass_list,
which currently always returns 0, so let's see where you change that.
Ah, you don't (it's in line 671 in this file). It's only in
jffs2_nand_1pass that you do a change, but even there we have a problem:
> diff --git a/fs/jffs2/jffs2_nand_1pass.c b/fs/jffs2/jffs2_nand_1pass.c
> index 9bad690..885fa3c 100644
> --- a/fs/jffs2/jffs2_nand_1pass.c
> +++ b/fs/jffs2/jffs2_nand_1pass.c
> @@ -251,6 +251,7 @@ jffs_init_1pass_list(struct part_info *part)
> pL->dir.listCompare = compare_dirents;
> pL->frag.listCompare = compare_inodes;
> #endif
> + return 1;
When malloc fails, we get no error output.
> }
> return 0;
> }
> @@ -806,7 +807,9 @@ jffs2_1pass_build_lists(struct part_info * part)
> nand = nand_info + id->num;
>
> /* if we are building a list we need to refresh the cache. */
> - jffs_init_1pass_list(part);
> + if(! jffs_init_1pass_list(part))
> + return 0;
> +
And the caller fails also, so the user in this case will see no error
message and no output. Not good.
Cheers
Detlev
--
F?r jemanden, der in eine Religion geboren wurde, in der das Ringen um eine
einzige Seele ein Stafettenlauf ?ber viele Jahrhunderte sein kann [..], hat
das Tempo des Christentums etwas Schwindelerregendes. Wenn der Hinduismus
friedlich dahinflie?t wie der Ganges, dann ist das Christentum Toronto in
der Rushhour. -- Yann Martel
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
next prev parent reply other threads:[~2011-04-29 13:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-24 3:37 [U-Boot] [PATCH 4/7] JFFS2: Improve error checking Baidu Liu
2011-04-29 13:18 ` Detlev Zundel [this message]
2011-04-29 15:02 ` Baidu Liu
2011-04-29 17:31 ` Detlev Zundel
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=m2sjt142n5.fsf@ohwell.denx.de \
--to=dzu@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 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.