aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLizhi Xu <[email protected]>2024-09-02 10:36:36 +0800
committerAndrew Morton <[email protected]>2024-09-09 15:15:54 -0700
commit33b525cef4cff49e216e4133cc48452e11c0391e (patch)
tree99182cc87b673503c3b28031086409fcaaad4ef9
parentc03a82b4a0c935774afa01fd6d128b444fd930a1 (diff)
ocfs2: fix possible null-ptr-deref in ocfs2_set_buffer_uptodate
When doing cleanup, if flags without OCFS2_BH_READAHEAD, it may trigger NULL pointer dereference in the following ocfs2_set_buffer_uptodate() if bh is NULL. Link: https://lkml.kernel.org/r/[email protected] Fixes: cf76c78595ca ("ocfs2: don't put and assigning null to bh allocated outside") Signed-off-by: Lizhi Xu <[email protected]> Signed-off-by: Joseph Qi <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Reported-by: Heming Zhao <[email protected]> Suggested-by: Heming Zhao <[email protected]> Cc: <[email protected]> [4.20+] Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Joel Becker <[email protected]> Cc: Jun Piao <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Mark Fasheh <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--fs/ocfs2/buffer_head_io.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
index e62c7e1de4eb..8f714406528d 100644
--- a/fs/ocfs2/buffer_head_io.c
+++ b/fs/ocfs2/buffer_head_io.c
@@ -388,7 +388,8 @@ read_failure:
/* Always set the buffer in the cache, even if it was
* a forced read, or read-ahead which hasn't yet
* completed. */
- ocfs2_set_buffer_uptodate(ci, bh);
+ if (bh)
+ ocfs2_set_buffer_uptodate(ci, bh);
}
ocfs2_metadata_cache_io_unlock(ci);