public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: Fix error pointer dereference
@ 2026-02-18 19:51 Ethan Tidmore
  2026-02-18 23:49 ` Darrick J. Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ethan Tidmore @ 2026-02-18 19:51 UTC (permalink / raw)
  To: Carlos Maiolino, NeilBrown
  Cc: Christian Brauner, linux-xfs, linux-kernel, Ethan Tidmore

The function try_lookup_noperm() can return an error pointer and is not
checked for one. Add checks for error pointer.

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: 06c567403ae5a ("Use try_lookup_noperm() instead of d_hash_and_lookup() outside of VFS")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 fs/xfs/scrub/orphanage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/scrub/orphanage.c b/fs/xfs/scrub/orphanage.c
index 52a108f6d5f4..cdb0f486f50c 100644
--- a/fs/xfs/scrub/orphanage.c
+++ b/fs/xfs/scrub/orphanage.c
@@ -442,7 +442,7 @@ xrep_adoption_check_dcache(
 		return 0;
 
 	d_child = try_lookup_noperm(&qname, d_orphanage);
-	if (d_child) {
+	if (!IS_ERR_OR_NULL(d_child)) {
 		trace_xrep_adoption_check_child(sc->mp, d_child);
 
 		if (d_is_positive(d_child)) {
@@ -479,7 +479,7 @@ xrep_adoption_zap_dcache(
 		return;
 
 	d_child = try_lookup_noperm(&qname, d_orphanage);
-	while (d_child != NULL) {
+	while (!IS_ERR_OR_NULL(d_child)) {
 		trace_xrep_adoption_invalidate_child(sc->mp, d_child);
 
 		ASSERT(d_is_negative(d_child));
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-02-19 16:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-18 19:51 [PATCH] xfs: Fix error pointer dereference Ethan Tidmore
2026-02-18 23:49 ` Darrick J. Wong
2026-02-19  0:25   ` NeilBrown
2026-02-19  0:31     ` Darrick J. Wong
2026-02-19  0:21 ` NeilBrown
2026-02-19 11:26 ` Nirjhar Roy (IBM)
2026-02-19 16:46   ` Ethan Tidmore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox