Rather, it can be done as below. Nothing to say that
your code wouldn't work. Just that catch it early, so that potential
function call overhead to call xfs_free_buftarg can be avoided.
xfs_unmountfs_close(xfs_mount_t *mp, struct cred *cr)
if (mp->m_logdev_targp && (mp->m_logdev_targp != mp->m_ddev_targp))
Jesper Juhl wrote:
(got no reply on this when I originally send it on 20061031, so resending
now that a bit of time has passed. The patch still applies cleanly to
Linus' git tree as of today.)
The Coverity checker spotted a potential problem in XFS.
The problem is that if, in xfs_mount(), this code triggers:
Then we'll end up calling xfs_unmountfs_close() with a NULL
This in turn will result in a call to xfs_free_buftarg() with its 'btp'
argument == NULL. xfs_free_buftarg() dereferences 'btp' leading to
a NULL pointer dereference and crash.
I think this can happen, since the fatal call to xfs_free_buftarg()
happens when 'm_logdev_targp != m_ddev_targp' and due to a check of
'm_ddev_targp' against NULL in xfs_mount() (and subsequent return if it is
NULL) the two will never both be NULL when we hit the error0 label from
the two lines cited above.
Comments welcome (please keep me on Cc: on replies).
Here's a proposed patch to fix this by testing 'btp' against NULL in
Signed-off-by: Jesper Juhl <[email protected]>
fs/xfs/linux-2.6/xfs_buf.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index db5f5a3..6ef1860 100644
@@ -1450,6 +1450,9 @@ xfs_free_buftarg(
+ if (unlikely(!btp))
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Video 4 Linux]
[Linux for the blind]