ubifs: do not decide upon uninitialized variable
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Fri, 25 Dec 2020 14:19:39 +0000 (15:19 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 20 Jan 2021 19:01:45 +0000 (14:01 -0500)
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>
fs/ubifs/io.c

index eb14b89..9962cbe 100644 (file)
@@ -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)