Skip to content

Commit 057bbf3

Browse files
adam900710jfvogel
authored andcommitted
btrfs: add the missing error handling inside get_canonical_dev_path
[ Upstream commit fe4de59 ] Inside function get_canonical_dev_path(), we call d_path() to get the final device path. But d_path() can return error, and in that case the next strscpy() call will trigger an invalid memory access. Add back the missing error handling for d_path(). Reported-by: Boris Burkov <[email protected]> Fixes: 7e06de7 ("btrfs: canonicalize the device path before adding it") Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit d0fb5741932b831eded49bfaaf33353e96200d6d) Signed-off-by: Jack Vogel <[email protected]>
1 parent 8531d1d commit 057bbf3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/btrfs/volumes.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,10 @@ static int get_canonical_dev_path(const char *dev_path, char *canonical)
797797
if (ret)
798798
goto out;
799799
resolved_path = d_path(&path, path_buf, PATH_MAX);
800+
if (IS_ERR(resolved_path)) {
801+
ret = PTR_ERR(resolved_path);
802+
goto out;
803+
}
800804
ret = strscpy(canonical, resolved_path, PATH_MAX);
801805
out:
802806
kfree(path_buf);

0 commit comments

Comments
 (0)