提交 d17a18dd 编写于 作者: D Dave Young 提交者: Linus Torvalds

pktcdvd: add kobject_put when kobject register fails

In kobject_register, the kobject reference is get in kobject_init, and then
kobject_add.  If kobject_add fail, it will only cleanup the reference got
by itself.
Signed-off-by: NDave Young <hidave.darkstar@gmail.com>
Reviewed-by: NPekka Enberg <penberg@cs.helsinki.fi>
Cc: Greg KH <greg@kroah.com>
Cc: Peter Osterlund <petero2@telia.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 bbd06825
......@@ -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;
}
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册