]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ubifs: Correctly use tnc_next() in search_dh_cookie()
authorRichard Weinberger <richard@nod.at>
Tue, 14 May 2019 20:31:08 +0000 (22:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Sep 2019 07:08:06 +0000 (09:08 +0200)
commit0369bbfe7ad21c1aea7b6379542eae810c8da278
tree7ca75951f099be4fa873ee2ae02d1c7e7d1e0d5a
parent75183476fea19b831e5814e5144d3136f3ee09c4
ubifs: Correctly use tnc_next() in search_dh_cookie()

commit bacfa94b08027b9f66ede7044972e3b066766b3e upstream.

Commit c877154d307f fixed an uninitialized variable and optimized
the function to not call tnc_next() in the first iteration of the
loop. While this seemed perfectly legit and wise, it turned out to
be illegal.
If the lookup function does not find an exact match it will rewind
the cursor by 1.
The rewinded cursor will not match the name hash we are looking for
and this results in a spurious -ENOENT.
So we need to move to the next entry in case of an non-exact match,
but not if the match was exact.

While we are here, update the documentation to avoid further confusion.

Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: c877154d307f ("ubifs: Fix uninitialized variable in search_dh_cookie()")
Fixes: 781f675e2d7e ("ubifs: Fix unlink code wrt. double hash lookups")
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ubifs/tnc.c