Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a71a742 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Greg Kroah-Hartman
Browse files

ubifs: Fix uninitialized variable in search_dh_cookie()




[ Upstream commit c877154d307f4a91e0b5b85b75535713dab945ae ]

fs/ubifs/tnc.c: In function ‘search_dh_cookie’:
fs/ubifs/tnc.c:1893: warning: ‘err’ is used uninitialized in this function

Indeed, err is always used uninitialized.

According to an original review comment from Hyunchul, acknowledged by
Richard, err should be initialized to -ENOENT to avoid the first call to
tnc_next().  But we can achieve the same by reordering the code.

Fixes: 781f675e ("ubifs: Fix unlink code wrt. double hash lookups")
Reported-by: default avatarHyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a1dfcb01
Loading
Loading
Loading
Loading
+7 −14
Original line number Diff line number Diff line
@@ -1890,36 +1890,29 @@ static int search_dh_cookie(struct ubifs_info *c, const union ubifs_key *key,
	union ubifs_key *dkey;

	for (;;) {
		if (!err) {
			err = tnc_next(c, &znode, n);
			if (err)
				goto out;
		}

		zbr = &znode->zbranch[*n];
		dkey = &zbr->key;

		if (key_inum(c, dkey) != key_inum(c, key) ||
		    key_type(c, dkey) != key_type(c, key)) {
			err = -ENOENT;
			goto out;
			return -ENOENT;
		}

		err = tnc_read_hashed_node(c, zbr, dent);
		if (err)
			goto out;
			return err;

		if (key_hash(c, key) == key_hash(c, dkey) &&
		    le32_to_cpu(dent->cookie) == cookie) {
			*zn = znode;
			goto out;
		}
			return 0;
		}

out:

		err = tnc_next(c, &znode, n);
		if (err)
			return err;
	}
}

static int do_lookup_dh(struct ubifs_info *c, const union ubifs_key *key,
			struct ubifs_dent_node *dent, uint32_t cookie)