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 <hidave.darkstar@gmail.com>
Reviewed-by: Pekka 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Dave Young and committed by
Linus Torvalds
d17a18dd bbd06825

+3 -1
+3 -1
drivers/block/pktcdvd.c
··· 117 117 p->kobj.parent = parent; 118 118 p->kobj.ktype = ktype; 119 119 p->pd = pd; 120 - if (kobject_register(&p->kobj) != 0) 120 + if (kobject_register(&p->kobj) != 0) { 121 + kobject_put(&p->kobj); 121 122 return NULL; 123 + } 122 124 return p; 123 125 } 124 126 /*