From 8811249f0cfdd6552152173f881fddc7f20f427e Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Thu, 11 Apr 2019 12:28:02 +0800 Subject: vfs: update d_make_root() description Clearify d_make_root() usage, error handling and cleanup requirements. Signed-off-by: Ian Kent Signed-off-by: Al Viro --- Documentation/filesystems/porting | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index 3bd1148d8bb6..f6714f7e6bb5 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting @@ -428,8 +428,19 @@ release it yourself. -- [mandatory] d_alloc_root() is gone, along with a lot of bugs caused by code -misusing it. Replacement: d_make_root(inode). The difference is, -d_make_root() drops the reference to inode if dentry allocation fails. +misusing it. Replacement: d_make_root(inode). On success d_make_root(inode) +allocates and returns a new dentry instantiated with the passed in inode. +On failure NULL is returned and the passed in inode is dropped so the reference +to inode is consumed in all cases and failure handling need not do any cleanup +for the inode. If d_make_root(inode) is passed a NULL inode it returns NULL +and also requires no further error handling. Typical usage is: + + inode = foofs_new_inode(....); + s->s_root = d_make_inode(inode); + if (!s->s_root) + /* Nothing needed for the inode cleanup */ + return -ENOMEM; + ... -- [mandatory] -- cgit From 02e5ad973883c36c0868b301b8357d9c455bb91c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 26 Jun 2019 20:43:53 -0400 Subject: perf_event_get(): don't bother with fget_raw() ... since we immediately follow that with check that it *is* an opened perf file, with O_PATH ones ending with with the same -EBADF we'd get for descriptor that isn't opened at all. Signed-off-by: Al Viro --- kernel/events/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index abbd4b3b96c2..f9ff04c8d084 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11554,9 +11554,7 @@ void perf_event_delayed_put(struct task_struct *task) struct file *perf_event_get(unsigned int fd) { - struct file *file; - - file = fget_raw(fd); + struct file *file = fget(fd); if (!file) return ERR_PTR(-EBADF); -- cgit