aboutsummaryrefslogtreecommitdiffstats
path: root/fs/libfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/libfs.c')
-rw-r--r--fs/libfs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/libfs.c b/fs/libfs.c
index 8debe7b33769..62baa0387d6e 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -925,6 +925,8 @@ EXPORT_SYMBOL(generic_file_fsync);
925int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks) 925int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks)
926{ 926{
927 u64 last_fs_block = num_blocks - 1; 927 u64 last_fs_block = num_blocks - 1;
928 u64 last_fs_page =
929 last_fs_block >> (PAGE_CACHE_SHIFT - blocksize_bits);
928 930
929 if (unlikely(num_blocks == 0)) 931 if (unlikely(num_blocks == 0))
930 return 0; 932 return 0;
@@ -932,10 +934,8 @@ int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks)
932 if ((blocksize_bits < 9) || (blocksize_bits > PAGE_CACHE_SHIFT)) 934 if ((blocksize_bits < 9) || (blocksize_bits > PAGE_CACHE_SHIFT))
933 return -EINVAL; 935 return -EINVAL;
934 936
935 if ((last_fs_block > 937 if ((last_fs_block > (sector_t)(~0ULL) >> (blocksize_bits - 9)) ||
936 (sector_t)(~0ULL) >> (blocksize_bits - 9)) || 938 (last_fs_page > (pgoff_t)(~0ULL))) {
937 (last_fs_block >
938 (pgoff_t)(~0ULL) >> (PAGE_CACHE_SHIFT - blocksize_bits))) {
939 return -EFBIG; 939 return -EFBIG;
940 } 940 }
941 return 0; 941 return 0;