Commit 5e971dce authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

proc: drop several "PDE valid/invalid" checks

proc-misc code is noticeably full of "if (de)" checks when PDE passed is
always valid.  Remove them.

Addition of such check in proc_lookup_de() is for failed lookup case.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7cee4e00
...@@ -388,7 +388,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, ...@@ -388,7 +388,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
lock_kernel(); lock_kernel();
spin_lock(&proc_subdir_lock); spin_lock(&proc_subdir_lock);
if (de) {
for (de = de->subdir; de ; de = de->next) { for (de = de->subdir; de ; de = de->next) {
if (de->namelen != dentry->d_name.len) if (de->namelen != dentry->d_name.len)
continue; continue;
...@@ -403,7 +402,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, ...@@ -403,7 +402,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
goto out_unlock; goto out_unlock;
} }
} }
}
spin_unlock(&proc_subdir_lock); spin_unlock(&proc_subdir_lock);
out_unlock: out_unlock:
unlock_kernel(); unlock_kernel();
...@@ -413,6 +411,7 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, ...@@ -413,6 +411,7 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
d_add(dentry, inode); d_add(dentry, inode);
return NULL; return NULL;
} }
if (de)
de_put(de); de_put(de);
return ERR_PTR(error); return ERR_PTR(error);
} }
...@@ -443,10 +442,6 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent, ...@@ -443,10 +442,6 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
lock_kernel(); lock_kernel();
ino = inode->i_ino; ino = inode->i_ino;
if (!de) {
ret = -EINVAL;
goto out;
}
i = filp->f_pos; i = filp->f_pos;
switch (i) { switch (i) {
case 0: case 0:
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
struct proc_dir_entry *de_get(struct proc_dir_entry *de) struct proc_dir_entry *de_get(struct proc_dir_entry *de)
{ {
if (de)
atomic_inc(&de->count); atomic_inc(&de->count);
return de; return de;
} }
...@@ -35,7 +34,6 @@ struct proc_dir_entry *de_get(struct proc_dir_entry *de) ...@@ -35,7 +34,6 @@ struct proc_dir_entry *de_get(struct proc_dir_entry *de)
*/ */
void de_put(struct proc_dir_entry *de) void de_put(struct proc_dir_entry *de)
{ {
if (de) {
lock_kernel(); lock_kernel();
if (!atomic_read(&de->count)) { if (!atomic_read(&de->count)) {
printk("de_put: entry %s already free!\n", de->name); printk("de_put: entry %s already free!\n", de->name);
...@@ -46,7 +44,6 @@ void de_put(struct proc_dir_entry *de) ...@@ -46,7 +44,6 @@ void de_put(struct proc_dir_entry *de)
if (atomic_dec_and_test(&de->count)) if (atomic_dec_and_test(&de->count))
free_proc_entry(de); free_proc_entry(de);
unlock_kernel(); unlock_kernel();
}
} }
/* /*
...@@ -392,7 +389,7 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, ...@@ -392,7 +389,7 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
{ {
struct inode * inode; struct inode * inode;
if (de != NULL && !try_module_get(de->owner)) if (!try_module_get(de->owner))
goto out_mod; goto out_mod;
inode = iget_locked(sb, ino); inode = iget_locked(sb, ino);
...@@ -402,7 +399,7 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, ...@@ -402,7 +399,7 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
PROC_I(inode)->fd = 0; PROC_I(inode)->fd = 0;
PROC_I(inode)->pde = de; PROC_I(inode)->pde = de;
if (de) {
if (de->mode) { if (de->mode) {
inode->i_mode = de->mode; inode->i_mode = de->mode;
inode->i_uid = de->uid; inode->i_uid = de->uid;
...@@ -427,13 +424,11 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, ...@@ -427,13 +424,11 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
inode->i_fop = de->proc_fops; inode->i_fop = de->proc_fops;
} }
} }
}
unlock_new_inode(inode); unlock_new_inode(inode);
} }
return inode; return inode;
out_ino: out_ino:
if (de != NULL)
module_put(de->owner); module_put(de->owner);
out_mod: out_mod:
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment