mm/shmem.c: Fix the missing unaccount on the failed path
Subsystems (2)
PATCH 1/1 mm/shmem.c: Fix the missing unaccount on the failed path
In function __shmem_file_setup(), shmem_unacct_size() is forgotten on the failed path, so add it.
--- mm/shmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/shmem.c +3 -1
@@ -4200,8 +4200,10 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, lif (!IS_ERR (res)) res =alloc_file_pseudo (inode, mnt, name,O_RDWR , &shmem_file_operations); -if (IS_ERR (res)) +if (IS_ERR (res)) {iput (inode); +shmem_unacct_size (flags, size); + }return res; }
Signature · 1 line
2.19.1.3.ge56e4f7
Hugh Dickins
maintainerQuoted 28 lines · Tianjia Zhang
In function
__shmem_file_setup(),shmem_unacct_size()is forgotten on the failed path, so add it.Fixes 93dec2da7b234 ("... and switch shmem_file_setup() to alloc_file_pseudo()")Cc Al Viro <[email protected]>Signed-off-by Tianjia Zhang <[email protected]>--- mm/shmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)mm/shmem.c +3
-1@@ -4200,8 +4200,10 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, lif (!IS_ERR (res)) res =alloc_file_pseudo (inode, mnt, name,O_RDWR , &shmem_file_operations); -if (IS_ERR (res)) +if (IS_ERR (res)) {iput (inode); +shmem_unacct_size (flags, size); + }return res; }Signature · 1 line
2.19.1.3.ge56e4f7
Looks mistaken to me.
Is this something you noticed by source inspection, or something you have observed in practice?
I haven't tried exercising this path while injecting errors into alloc_file_pseudo(); but what I'd expect to happen is that the iput(inode), which you see already on that error path, will get to evict the inode, which will entail calling shmem_evict_inode(), which does that shmem_unacct_size() itself.
Hugh
Quoted 36 lines · Hugh Dickins
Quoted 28 lines · Tianjia Zhang
In function
__shmem_file_setup(),shmem_unacct_size()is forgotten on the failed path, so add it.Fixes 93dec2da7b234 ("... and switch shmem_file_setup() to alloc_file_pseudo()")Cc Al Viro <[email protected]>Signed-off-by Tianjia Zhang <[email protected]>--- mm/shmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)mm/shmem.c +3
-1@@ -4200,8 +4200,10 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, lif (!IS_ERR (res)) res =alloc_file_pseudo (inode, mnt, name,O_RDWR , &shmem_file_operations); -if (IS_ERR (res)) +if (IS_ERR (res)) {iput (inode); +shmem_unacct_size (flags, size); + }return res; }Signature · 1 line
2.19.1.3.ge56e4f7Looks mistaken to me.
Is this something you noticed by source inspection, or something you have observed in practice?
Quoted 8 lines
I haven't tried exercising this path while injecting errors into
alloc_file_pseudo(); but what I'd expect to happen is that the iput(inode), which you see already on that error path, will get to evict the inode, which will entail callingshmem_evict_inode(), which does thatshmem_unacct_size()itself.Hugh
I noticed by looking at the code. you are right, I neglected this point, thanks for your explanation.
Thanks,
Tianjia