Skip to content

Commit 7144801

Browse files
committed
proc: Clear the pieces of proc_inode that proc_evict_inode cares about
This just keeps everything tidier, and allows for using flags like SLAB_TYPESAFE_BY_RCU where slabs are not always cleared before reuse. I don't see reuse without reinitializing happening with the proc_inode but I had a false alarm while reworking flushing of proc dentries and indoes when a process dies that caused me to tidy this up. The code is a little easier to follow and reason about this way so I figured the changes might as well be kept. Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent f90f3ca commit 7144801

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

fs/proc/inode.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,27 @@ static void proc_evict_inode(struct inode *inode)
3333
{
3434
struct proc_dir_entry *de;
3535
struct ctl_table_header *head;
36+
struct proc_inode *ei = PROC_I(inode);
3637

3738
truncate_inode_pages_final(&inode->i_data);
3839
clear_inode(inode);
3940

4041
/* Stop tracking associated processes */
41-
put_pid(PROC_I(inode)->pid);
42+
if (ei->pid) {
43+
put_pid(ei->pid);
44+
ei->pid = NULL;
45+
}
4246

4347
/* Let go of any associated proc directory entry */
44-
de = PDE(inode);
45-
if (de)
48+
de = ei->pde;
49+
if (de) {
4650
pde_put(de);
51+
ei->pde = NULL;
52+
}
4753

48-
head = PROC_I(inode)->sysctl;
54+
head = ei->sysctl;
4955
if (head) {
50-
RCU_INIT_POINTER(PROC_I(inode)->sysctl, NULL);
56+
RCU_INIT_POINTER(ei->sysctl, NULL);
5157
proc_sys_evict_inode(inode, head);
5258
}
5359
}

0 commit comments

Comments
 (0)