Re: [PATCH] cachefiles: fix dentry leak in cachefiles_open_file()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024/8/26 21:55, Markus Elfring wrote:
Add the missing dput() to cachefiles_open_file() for a quick fix.
I suggest to use a goto chain accordingly.


…

Hi Markus,


Thanks for the suggestion, but I think the current solution is simple
enough that we don't need to add a label to it.

Actually, at first I was going to release the reference count of the
dentry uniformly in cachefiles_look_up_object() and delete all dput()
in cachefiles_open_file(), but this may conflict when backporting
the code to stable. So just keep it simple to facilitate backporting
to stable.

Thanks,
Baokun
+++ b/fs/cachefiles/namei.c
@@ -554,6 +554,7 @@ static bool cachefiles_open_file(struct cachefiles_object *object,
  	if (!cachefiles_mark_inode_in_use(object, d_inode(dentry))) {
  		pr_notice("cachefiles: Inode already in use: %pd (B=%lx)\n",
  			  dentry, d_inode(dentry)->i_ino);
+		dput(dentry);
  		return false;
Please replace two statements by the statement “goto put_dentry;”.


…
error:
	cachefiles_do_unmark_inode_in_use(object, d_inode(dentry));
+put_dentry:
	dput(dentry);
	return false;
}
Regards,
Markus

--
With Best Regards,
Baokun Li





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux