btrfs: fix NULL pointer dereference in do_abort_log_replay
PATCH 1/1 btrfs: fix NULL pointer dereference in do_abort_log_replay
Coverity reported a NULL pointer dereference issue (CID 1666756) in do_abort_log_replay(). When btrfs_alloc_path() fails in replay_one_buffer(), wc->subvol_path is NULL, but btrfs_abort_log_replay() calls do_abort_log_replay() which unconditionally dereferences wc->subvol_path when attempting to print debug information. Fix this by adding a NULL check before dereferencing wc->subvol_path in do_abort_log_replay().
--- fs/btrfs/tree-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-log.c +1 -1
@@ -190,7 +190,7 @@ static void do_abort_log_replay(struct walk_control *wc, const char *function,btrfs_abort_transaction (wc->trans, error); -if (wc->subvol_path->nodes[0 ]) { +if (wc->subvol_path && wc->subvol_path->nodes[0 ]) {btrfs_crit (fs_info,"subvolume (root %llu) leaf currently being processed:" ,btrfs_root_id (wc->root));
Signature · 1 line
2.52.0
Quoted 10 lines · Suchit Karunakaran
Coverity reported a NULL pointer dereference issue (CID 1666756) in
do_abort_log_replay(). Whenbtrfs_alloc_path()fails inreplay_one_buffer(),wc->subvol_pathis NULL, butbtrfs_abort_log_replay()callsdo_abort_log_replay()which unconditionally dereferenceswc->subvol_pathwhen attempting to print debug information. Fix this by adding a NULL check before dereferencingwc->subvol_pathindo_abort_log_replay().Signed-off-by Suchit Karunakaran <[email protected]>
Thanks, I'll add it to the for-next github branch with a proper Fixes tag.
Quoted 21 lines
--- fs/btrfs/tree-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/tree-log.c +1
-2@@ -190,7 +190,7 @@ static void do_abort_log_replay(struct walk_control *wc, const char *function,btrfs_abort_transaction (wc->trans, error); -if (wc->subvol_path->nodes[0 ]) { +if (wc->subvol_path && wc->subvol_path->nodes[0 ]) {btrfs_crit (fs_info,"subvolume (root %llu) leaf currently being processed:" ,btrfs_root_id (wc->root)); --2.52.0