]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/block/pktcdvd.c
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzi...
[linux-2.6-omap-h63xx.git] / drivers / block / pktcdvd.c
index a8130a4ad6d4329572b722b2947059db776fa8e2..3535ef896677a28dcc352654c880587e9bc463c2 100644 (file)
@@ -117,8 +117,10 @@ static struct pktcdvd_kobj* pkt_kobj_create(struct pktcdvd_device *pd,
        p->kobj.parent = parent;
        p->kobj.ktype = ktype;
        p->pd = pd;
-       if (kobject_register(&p->kobj) != 0)
+       if (kobject_register(&p->kobj) != 0) {
+               kobject_put(&p->kobj);
                return NULL;
+       }
        return p;
 }
 /*
@@ -358,10 +360,19 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
                                        size_t count)
 {
        unsigned int major, minor;
+
        if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
+               /* pkt_setup_dev() expects caller to hold reference to self */
+               if (!try_module_get(THIS_MODULE))
+                       return -ENODEV;
+
                pkt_setup_dev(MKDEV(major, minor), NULL);
+
+               module_put(THIS_MODULE);
+
                return count;
        }
+
        return -EINVAL;
 }