Commit d99c48c6 authored by Andrew Morton's avatar Andrew Morton Committed by Dave Jones

[PATCH] Add error checking get_disk()

Patch from Bob Miller <rem@osdl.org>

The get_disk() function should check the return value from kobject_get()
before passing it to to_disk().  This patch fixes this error.

(Acked by Pat)
parent 18f3cae2
......@@ -538,12 +538,20 @@ struct gendisk *alloc_disk(int minors)
struct gendisk *get_disk(struct gendisk *disk)
{
struct module *owner;
struct kobject *kobj;
if (!disk->fops)
return NULL;
owner = disk->fops->owner;
if (owner && !try_module_get(owner))
return NULL;
return to_disk(kobject_get(&disk->kobj));
kobj = kobject_get(&disk->kobj);
if (kobj == NULL) {
module_put(owner);
return NULL;
}
return to_disk(kobj);
}
void put_disk(struct gendisk *disk)
......
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