Skip to content

Commit 33b525c

Browse files
Lizhi Xuakpm00
authored andcommitted
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: cf76c78 ("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]>
1 parent c03a82b commit 33b525c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/ocfs2/buffer_head_io.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
388388
/* Always set the buffer in the cache, even if it was
389389
* a forced read, or read-ahead which hasn't yet
390390
* completed. */
391-
ocfs2_set_buffer_uptodate(ci, bh);
391+
if (bh)
392+
ocfs2_set_buffer_uptodate(ci, bh);
392393
}
393394
ocfs2_metadata_cache_io_unlock(ci);
394395

0 commit comments

Comments
 (0)