All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Packham <judge.packham@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 1/1] ubifs: do not decide upon uninitialized variable
Date: Sat, 26 Dec 2020 20:08:52 +1300	[thread overview]
Message-ID: <CAFOYHZBOO8cz7ykreRVsWHRYyCgUZGqpR-mBTjhmyGtW9XhkeQ@mail.gmail.com> (raw)
In-Reply-To: <20201225141939.35426-1-xypron.glpk@gmx.de>

(note replying on mobile device only code access is via git.denx.de)

On Sat, 26 Dec 2020, 3:19 AM Heinrich Schuchardt, <xypron.glpk@gmx.de>
wrote:

> Before 'if (err)' we have to initialize the variable otherwise we use a
> random value from the stack.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>

In all the cases below err might be uninitialised because the code that
would otherwise initialise it has been conditionally excluded with #ifndef
__UBOOT__. I wonder if we could do something cleaner by making
dbg_leb_change() etc do something suitable (return 0 or -Esomething).

 fs/ubifs/io.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
> index eb14b89544..9962cbe7eb 100644
> --- a/fs/ubifs/io.c
> +++ b/fs/ubifs/io.c
> @@ -114,7 +114,7 @@ int ubifs_leb_read(const struct ubifs_info *c, int
> lnum, void *buf, int offs,
>  int ubifs_leb_write(struct ubifs_info *c, int lnum, const void *buf, int
> offs,
>                     int len)
>  {
> -       int err;
> +       int err = 0;
>
>         ubifs_assert(!c->ro_media && !c->ro_mount);
>         if (c->ro_error)
> @@ -136,7 +136,7 @@ int ubifs_leb_write(struct ubifs_info *c, int lnum,
> const void *buf, int offs,
>
>  int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int
> len)
>  {
> -       int err;
> +       int err = 0;
>
>         ubifs_assert(!c->ro_media && !c->ro_mount);
>         if (c->ro_error)
> @@ -158,7 +158,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum,
> const void *buf, int len)
>
>  int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
>  {
> -       int err;
> +       int err = 0;
>
>         ubifs_assert(!c->ro_media && !c->ro_mount);
>         if (c->ro_error)
> @@ -179,7 +179,7 @@ int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
>
>  int ubifs_leb_map(struct ubifs_info *c, int lnum)
>  {
> -       int err;
> +       int err = 0;
>
>         ubifs_assert(!c->ro_media && !c->ro_mount);
>         if (c->ro_error)
> --
> 2.29.2
>
>

  reply	other threads:[~2020-12-26  7:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-25 14:19 [PATCH 1/1] ubifs: do not decide upon uninitialized variable Heinrich Schuchardt
2020-12-26  7:08 ` Chris Packham [this message]
2020-12-26  7:34   ` Heinrich Schuchardt
2020-12-27  7:38     ` Chris Packham
2021-01-20 21:46 ` Tom Rini

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=CAFOYHZBOO8cz7ykreRVsWHRYyCgUZGqpR-mBTjhmyGtW9XhkeQ@mail.gmail.com \
    --to=judge.packham@gmail.com \
    --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.