Commit afe0458b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] avoid deprecated module functions in core code

A second start at removing them from kernel/*.c and fs/*.c.

Note that module_put is fine for a NULL argument.
parent 2cdea215
......@@ -29,8 +29,7 @@ static inline int crypto_alg_get(struct crypto_alg *alg)
static inline void crypto_alg_put(struct crypto_alg *alg)
{
if (alg->cra_module)
__MOD_DEC_USE_COUNT(alg->cra_module);
module_put(alg->cra_module);
}
struct crypto_alg *crypto_alg_lookup(const char *name)
......
......@@ -168,15 +168,13 @@ get_gendisk(dev_t dev, int *part)
best = p->range;
*part = dev - p->dev;
if (p->lock && p->lock(dev, data) < 0) {
if (owner)
__MOD_DEC_USE_COUNT(owner);
module_put(owner);
continue;
}
read_unlock(&gendisk_lock);
disk = probe(dev, part, data);
/* Currently ->owner protects _only_ ->probe() itself. */
if (owner)
__MOD_DEC_USE_COUNT(owner);
module_put(owner);
if (disk)
return disk;
goto retry;
......
......@@ -623,8 +623,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
}
} else {
put_disk(disk);
if (owner)
__MOD_DEC_USE_COUNT(owner);
module_put(owner);
if (bdev->bd_contains == bdev) {
if (bdev->bd_disk->fops->open) {
ret = bdev->bd_disk->fops->open(inode, file);
......@@ -651,8 +650,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
blkdev_put(bdev->bd_contains, BDEV_RAW);
bdev->bd_contains = NULL;
put_disk(disk);
if (owner)
__MOD_DEC_USE_COUNT(owner);
module_put(owner);
out:
up(&bdev->bd_sem);
unlock_kernel();
......@@ -723,9 +721,10 @@ int blkdev_put(struct block_device *bdev, int kind)
}
if (!bdev->bd_openers) {
struct module *owner = disk->fops->owner;
put_disk(disk);
if (owner)
__MOD_DEC_USE_COUNT(owner);
module_put(owner);
bdev->bd_disk = NULL;
bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
if (bdev != bdev->bd_contains) {
......
......@@ -111,8 +111,7 @@ static struct quota_format_type *find_quota_format(int id)
static void put_quota_format(struct quota_format_type *fmt)
{
if (fmt->qf_owner)
__MOD_DEC_USE_COUNT(fmt->qf_owner);
module_put(fmt->qf_owner);
}
/*
......
......@@ -102,8 +102,7 @@ int unregister_binfmt(struct linux_binfmt * fmt)
static inline void put_binfmt(struct linux_binfmt * fmt)
{
if (fmt->module)
__MOD_DEC_USE_COUNT(fmt->module);
module_put(fmt->module);
}
/*
......@@ -1108,14 +1107,18 @@ int do_execve(char * filename, char ** argv, char ** envp, struct pt_regs * regs
return retval;
}
void set_binfmt(struct linux_binfmt *new)
int set_binfmt(struct linux_binfmt *new)
{
struct linux_binfmt *old = current->binfmt;
if (new && new->module)
__MOD_INC_USE_COUNT(new->module);
if (new) {
if (!try_module_get(new->module))
return -1;
}
current->binfmt = new;
if (old && old->module)
__MOD_DEC_USE_COUNT(old->module);
if (old)
module_put(old->module);
return 0;
}
#define CORENAME_MAX_SIZE 64
......
......@@ -245,8 +245,7 @@ struct nls_table *load_nls(char *charset)
void unload_nls(struct nls_table *nls)
{
if (nls->owner)
__MOD_DEC_USE_COUNT(nls->owner);
module_put(nls->owner);
}
wchar_t charset2uni[256] = {
......
......@@ -565,8 +565,7 @@ char *partition_name(dev_t dev)
dname->name = NULL;
if (hd) {
dname->name = disk_name(hd, part, dname->namebuf);
if (hd->fops->owner)
__MOD_DEC_USE_COUNT(hd->fops->owner);
module_put(hd->fops->owner);
put_disk(hd);
}
if (!dname->name) {
......
......@@ -58,13 +58,7 @@ extern int copy_strings(int argc,char ** argv,struct linux_binprm *bprm);
extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm);
extern void compute_creds(struct linux_binprm *binprm);
extern int do_coredump(long signr, int exit_code, struct pt_regs * regs);
extern void set_binfmt(struct linux_binfmt *new);
#if 0
/* this went away now */
#define change_ldt(a,b) setup_arg_pages(a,b)
#endif
extern int set_binfmt(struct linux_binfmt *new);
#endif /* __KERNEL__ */
#endif /* _LINUX_BINFMTS_H */
......@@ -983,13 +983,13 @@ struct super_block *get_sb_pseudo(struct file_system_type *, char *,
/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
#define fops_get(fops) \
(((fops) && (fops)->owner) \
? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \
? (try_inc_mod_count((fops)->owner) ? (fops) : NULL) \
: (fops))
#define fops_put(fops) \
do { \
if ((fops) && (fops)->owner) \
__MOD_DEC_USE_COUNT((fops)->owner); \
module_put((fops)->owner); \
} while(0)
extern int register_filesystem(struct file_system_type *);
......
......@@ -107,22 +107,4 @@ struct exec_domain {
#define set_personality(pers) \
((current->personality == pers) ? 0 : __set_personality(pers))
/*
* Load an execution domain.
*/
#define get_exec_domain(ep) \
do { \
if (ep != NULL && ep->module != NULL) \
__MOD_INC_USE_COUNT(ep->module); \
} while (0)
/*
* Unload an execution domain.
*/
#define put_exec_domain(ep) \
do { \
if (ep != NULL && ep->module != NULL) \
__MOD_DEC_USE_COUNT(ep->module); \
} while (0)
#endif /* _LINUX_PERSONALITY_H */
......@@ -172,7 +172,7 @@ __set_personality(u_long personality)
fsp = copy_fs_struct(current->fs);
if (fsp == NULL) {
put_exec_domain(ep);
module_put(ep->module);
return -ENOMEM;;
}
......@@ -194,10 +194,7 @@ __set_personality(u_long personality)
current_thread_info()->exec_domain = ep;
set_fs_altroot();
put_exec_domain(oep);
printk(KERN_DEBUG "[%s:%d]: set personality to %lx\n",
current->comm, current->pid, personality);
module_put(oep->module);
return 0;
}
......
......@@ -664,9 +664,9 @@ NORET_TYPE void do_exit(long code)
if (current->leader)
disassociate_ctty(1);
put_exec_domain(tsk->thread_info->exec_domain);
if (tsk->binfmt && tsk->binfmt->module)
__MOD_DEC_USE_COUNT(tsk->binfmt->module);
module_put(tsk->thread_info->exec_domain->module);
if (tsk->binfmt)
module_put(tsk->binfmt->module);
tsk->exit_code = code;
exit_notify();
......
......@@ -743,10 +743,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
if (nr_threads >= max_threads)
goto bad_fork_cleanup_count;
get_exec_domain(p->thread_info->exec_domain);
if (!try_module_get(p->thread_info->exec_domain->module))
goto bad_fork_cleanup_count;
if (p->binfmt && p->binfmt->module)
__MOD_INC_USE_COUNT(p->binfmt->module);
if (p->binfmt && !try_module_get(p->binfmt->module))
goto bad_fork_cleanup_put_domain;
#ifdef CONFIG_PREEMPT
/*
......@@ -958,9 +959,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,
bad_fork_cleanup:
if (p->pid > 0)
free_pidmap(p->pid);
put_exec_domain(p->thread_info->exec_domain);
if (p->binfmt && p->binfmt->module)
__MOD_DEC_USE_COUNT(p->binfmt->module);
if (p->binfmt)
module_put(p->binfmt->module);
bad_fork_cleanup_put_domain:
module_put(p->thread_info->exec_domain->module);
bad_fork_cleanup_count:
atomic_dec(&p->user->processes);
free_uid(p->user);
......
......@@ -166,7 +166,7 @@ void inter_module_put(const char *im_name)
ime = list_entry(tmp, struct inter_module_entry, list);
if (strcmp(ime->im_name, im_name) == 0) {
if (ime->owner)
__MOD_DEC_USE_COUNT(ime->owner);
module_put(ime->owner);
spin_unlock(&ime_lock);
return;
}
......
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