From: Dave Young Date: Tue, 18 Dec 2007 00:20:00 +0000 (-0800) Subject: pktcdvd: add kobject_put when kobject register fails X-Git-Tag: v2.6.24-rc6~40 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=d17a18dd92c91c784fcf7c785fa6bbf178fd0a6d;p=linux-2.6-omap-h63xx.git 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: Dave Young Reviewed-by: Pekka Enberg Cc: Greg KH Cc: Peter Osterlund Cc: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index a5ee21319d3..3535ef89667 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -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; } /*