Skip to content

Commit cddfa64

Browse files
Ethan Tidmorecmaiolino
authored andcommitted
xfs: Fix error pointer dereference
The function try_lookup_noperm() can return an error pointer and is not checked for one. Add checks for error pointer in xrep_adoption_check_dcache() and xrep_adoption_zap_dcache(). Detected by Smatch: fs/xfs/scrub/orphanage.c:449 xrep_adoption_check_dcache() error: 'd_child' dereferencing possible ERR_PTR() fs/xfs/scrub/orphanage.c:485 xrep_adoption_zap_dcache() error: 'd_child' dereferencing possible ERR_PTR() Fixes: 73597e3 ("xfs: ensure dentry consistency when the orphanage adopts a file") Cc: stable@vger.kernel.org # v6.16 Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 47553dd commit cddfa64

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fs/xfs/scrub/orphanage.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@ xrep_adoption_check_dcache(
442442
return 0;
443443

444444
d_child = try_lookup_noperm(&qname, d_orphanage);
445+
if (IS_ERR(d_child)) {
446+
dput(d_orphanage);
447+
return PTR_ERR(d_child);
448+
}
449+
445450
if (d_child) {
446451
trace_xrep_adoption_check_child(sc->mp, d_child);
447452

@@ -479,7 +484,7 @@ xrep_adoption_zap_dcache(
479484
return;
480485

481486
d_child = try_lookup_noperm(&qname, d_orphanage);
482-
while (d_child != NULL) {
487+
while (!IS_ERR_OR_NULL(d_child)) {
483488
trace_xrep_adoption_invalidate_child(sc->mp, d_child);
484489

485490
ASSERT(d_is_negative(d_child));

0 commit comments

Comments
 (0)