提交 b41305a3 编写于 作者: A Arnd Bergmann 提交者: Paul Mackerras

[PATCH] spufs: Fix oops when spufs module is not loaded

try_module_get returns true when NULL arguments, so
we first need to check if there is a module loaded before
getting the reference count.
Signed-off-by: NArnd Bergmann <arndb@de.ibm.com>
Signed-off-by: NPaul Mackerras <paulus@samba.org>
上级 d88cfffa
...@@ -37,11 +37,12 @@ asmlinkage long sys_spu_create(const char __user *name, ...@@ -37,11 +37,12 @@ asmlinkage long sys_spu_create(const char __user *name,
unsigned int flags, mode_t mode) unsigned int flags, mode_t mode)
{ {
long ret; long ret;
struct module *owner = spufs_calls.owner;
ret = -ENOSYS; ret = -ENOSYS;
if (try_module_get(spufs_calls.owner)) { if (owner && try_module_get(spufs_calls.owner)) {
ret = spufs_calls.create_thread(name, flags, mode); ret = spufs_calls.create_thread(name, flags, mode);
module_put(spufs_calls.owner); module_put(owner);
} }
return ret; return ret;
} }
...@@ -51,16 +52,17 @@ asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, __u32 __user *ustatus) ...@@ -51,16 +52,17 @@ asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, __u32 __user *ustatus)
long ret; long ret;
struct file *filp; struct file *filp;
int fput_needed; int fput_needed;
struct module *owner = spufs_calls.owner;
ret = -ENOSYS; ret = -ENOSYS;
if (try_module_get(spufs_calls.owner)) { if (owner && try_module_get(owner)) {
ret = -EBADF; ret = -EBADF;
filp = fget_light(fd, &fput_needed); filp = fget_light(fd, &fput_needed);
if (filp) { if (filp) {
ret = spufs_calls.spu_run(filp, unpc, ustatus); ret = spufs_calls.spu_run(filp, unpc, ustatus);
fput_light(filp, fput_needed); fput_light(filp, fput_needed);
} }
module_put(spufs_calls.owner); module_put(owner);
} }
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册