xfs: don't release NULL pip in xfs_filestream_lookup_ag()
PATCH 1/1 xfs: don't release NULL pip in xfs_filestream_lookup_ag()
If xfs_filestream_get_parent() fails, we have a null pip, goto out, and attempt to IRELE(NULL). This causes a null pointer dereference and BUG().
Fix this by testing for pip before trying to release it.
---
fs/xfs/xfs_filestream.c +2 -1
@@ -348,7 +348,8 @@ xfs_filestream_lookup_ag(if (xfs_filestream_pick_ag (pip, startag, &ag,0 ,0 )) ag =NULLAGNUMBER ; out: -IRELE (pip); +if (pip) +IRELE (pip);return ag; }
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 15 lines · Eric Sandeen
If
xfs_filestream_get_parent()fails, we have a null pip, goto out, and attempt to IRELE(NULL). This causes a null pointer dereference andBUG().Fix this by testing for pip before trying to release it.
Reported-by Adrien Nader <[email protected]>Signed-off-by Eric Sandeen <[email protected]>---
fs/xfs/xfs_filestream.c +0
-0
fs/xfs/xfs_filestream.c xfs_filestream_lookup_ag( · line 355
Quoted 9 lines
fs/xfs/xfs_filestream.c +2
-1@@ -348,7 +348,8 @@ xfs_filestream_lookup_ag(if (xfs_filestream_pick_ag (pip, startag, &ag,0 ,0 )) ag =NULLAGNUMBER ; out: -IRELE (pip); +if (pip) +IRELE (pip);return ag; }
I'd just convert the error case when get_parent fails to:
if (!pip) return NULLAGNUMBER;
rather than using the goto and adding conditional cleanup for this case.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 1/1 xfs: fix NULL pointer dereference in xfs_filestream_lookup_ag()
In reply to Eric SandeenIf xfs_filestream_get_parent() fails, we have a null pip, goto out, and attempt to IRELE(NULL). This causes a null pointer dereference and BUG().
Fix this by directly returning NULLAGNUMBER in this case.
---
V2: skip the goto, because Dave doesn't like it. ;)
fs/xfs/xfs_filestream.c +1 -1
@@ -322,7 +322,7 @@ xfs_filestream_lookup_ag( pip =xfs_filestream_get_parent (ip);if (!pip) - goto out; +return NULLAGNUMBER ; mru =xfs_mru_cache_lookup (mp->m_filestream, pip->i_ino);if (mru) {
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs