diff options
author | Christoph Hellwig <hch@lst.de> | 2024-02-19 07:27:12 +0100 |
---|---|---|
committer | Chandan Babu R <chandanbabu@kernel.org> | 2024-02-21 11:36:51 +0530 |
commit | 1cd81faaf61b42307e81f2dd173934005c220a64 (patch) | |
tree | 0e9b0f6281d008f2b1dad04977f613778411f6cc /mm/shmem.c | |
parent | e11381d83d72198565f4545d9988b4720288eb64 (diff) | |
download | linux-1cd81faaf61b42307e81f2dd173934005c220a64.tar.gz linux-1cd81faaf61b42307e81f2dd173934005c220a64.tar.bz2 linux-1cd81faaf61b42307e81f2dd173934005c220a64.zip |
shmem: move the shmem_mapping assert into shmem_get_folio_gfp
Move the check that the inode really is a shmemfs one from
shmem_read_folio_gfp to shmem_get_folio_gfp given that shmem_get_folio
can also be called from outside of shmem.c. Also turn it into a
WARN_ON_ONCE and error return instead of BUG_ON to be less severe.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 1900916aa84d..ad533b2f0721 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1972,6 +1972,9 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, int error; bool alloced; + if (WARN_ON_ONCE(!shmem_mapping(inode->i_mapping))) + return -EINVAL; + if (index > (MAX_LFS_FILESIZE >> PAGE_SHIFT)) return -EFBIG; repeat: @@ -4915,7 +4918,6 @@ struct folio *shmem_read_folio_gfp(struct address_space *mapping, struct folio *folio; int error; - BUG_ON(!shmem_mapping(mapping)); error = shmem_get_folio_gfp(inode, index, &folio, SGP_CACHE, gfp, NULL, NULL); if (error) |