Skip to content

Commit

Permalink
pktcdvd: add kobject_put when kobject register fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dave Young authored and Linus Torvalds committed Dec 18, 2007
1 parent bbd0682 commit d17a18d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
/*
Expand Down

0 comments on commit d17a18d

Please sign in to comment.