Skip to content

Commit f077638

Browse files
committed
pidfs: fix pidfs_free_pid()
Ensure that we handle the case where task creation fails and pid->attr was never accessed at all. Signed-off-by: Christian Brauner <[email protected]>
1 parent 4e3d1e6 commit f077638

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

fs/pidfs.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,20 @@ void pidfs_free_pid(struct pid *pid)
150150
*/
151151
VFS_WARN_ON_ONCE(pid->stashed);
152152

153-
if (IS_ERR(attr))
154-
return;
155-
156153
/*
157-
* Any dentry must've been wiped from the pid by now. Otherwise
158-
* there's a reference count bug.
154+
* This if an error occurred during e.g., task creation that
155+
* causes us to never go through the exit path.
159156
*/
160-
VFS_WARN_ON_ONCE(pid->stashed);
157+
if (unlikely(!attr))
158+
return;
159+
160+
/* This never had a pidfd created. */
161+
if (IS_ERR(attr))
162+
return;
161163

162-
xattrs = attr->xattrs;
164+
xattrs = no_free_ptr(attr->xattrs);
163165
if (xattrs)
164-
simple_xattrs_free(attr->xattrs, NULL);
166+
simple_xattrs_free(xattrs, NULL);
165167
}
166168

167169
#ifdef CONFIG_PROC_FS

0 commit comments

Comments
 (0)