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: MMI-PSA29.97-13-9~37969 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d17a18dd92c91c784fcf7c785fa6bbf178fd0a6d;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.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 a5ee21319d37..3535ef896677 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; } /*