mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-13 14:24:11 +08:00
ubifs: Fix uninitialized variable in search_dh_cookie()
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: 781f675e2d
("ubifs: Fix unlink code wrt. double hash lookups")
Reported-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
parent
a8750ddca9
commit
c877154d30
@ -1890,35 +1890,28 @@ static int search_dh_cookie(struct ubifs_info *c, const union ubifs_key *key,
|
|||||||
union ubifs_key *dkey;
|
union ubifs_key *dkey;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!err) {
|
|
||||||
err = tnc_next(c, &znode, n);
|
|
||||||
if (err)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
zbr = &znode->zbranch[*n];
|
zbr = &znode->zbranch[*n];
|
||||||
dkey = &zbr->key;
|
dkey = &zbr->key;
|
||||||
|
|
||||||
if (key_inum(c, dkey) != key_inum(c, key) ||
|
if (key_inum(c, dkey) != key_inum(c, key) ||
|
||||||
key_type(c, dkey) != key_type(c, key)) {
|
key_type(c, dkey) != key_type(c, key)) {
|
||||||
err = -ENOENT;
|
return -ENOENT;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tnc_read_hashed_node(c, zbr, dent);
|
err = tnc_read_hashed_node(c, zbr, dent);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
return err;
|
||||||
|
|
||||||
if (key_hash(c, key) == key_hash(c, dkey) &&
|
if (key_hash(c, key) == key_hash(c, dkey) &&
|
||||||
le32_to_cpu(dent->cookie) == cookie) {
|
le32_to_cpu(dent->cookie) == cookie) {
|
||||||
*zn = znode;
|
*zn = znode;
|
||||||
goto out;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
err = tnc_next(c, &znode, n);
|
||||||
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_lookup_dh(struct ubifs_info *c, const union ubifs_key *key,
|
static int do_lookup_dh(struct ubifs_info *c, const union ubifs_key *key,
|
||||||
|
Loading…
Reference in New Issue
Block a user