]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
shmem: set a_ops earlier in shmem_symlink
authorChristoph Hellwig <hch@lst.de>
Mon, 19 Feb 2024 06:27:11 +0000 (07:27 +0100)
committerChandan Babu R <chandanbabu@kernel.org>
Wed, 21 Feb 2024 06:06:50 +0000 (11:36 +0530)
Set the a_ops in shmem_symlink before reading a folio from the mapping
to prepare for asserting that shmem_get_folio is only called on shmem
mappings.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
mm/shmem.c

index f607b0cab7e4e2a0b8593fc0ecc32e5579649bdd..1900916aa84d13f722d36eba3d8006106e788f63 100644 (file)
@@ -3506,10 +3506,10 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
                inode->i_op = &shmem_short_symlink_operations;
        } else {
                inode_nohighmem(inode);
+               inode->i_mapping->a_ops = &shmem_aops;
                error = shmem_get_folio(inode, 0, &folio, SGP_WRITE);
                if (error)
                        goto out_remove_offset;
-               inode->i_mapping->a_ops = &shmem_aops;
                inode->i_op = &shmem_symlink_inode_operations;
                memcpy(folio_address(folio), symname, len);
                folio_mark_uptodate(folio);