On Dec 4, 2007 3:45 PM, Pekka Enberg <[email protected]> wrote:
> Hi Dave,
>
> On Dec 4, 2007 3:31 AM, Dave Young <[email protected]> wrote:
> > Kobject_put should be called when kobject register functioin fails, so the
> > the kobj ref count touch zero and then the proper cleanup routines will be
> > called.
>
> [snip]
>
> > diff -upr linux/drivers/block/pktcdvd.c linux.new/drivers/block/pktcdvd.c
> > --- linux/drivers/block/pktcdvd.c 2007-11-30 13:13:44.000000000 +0800
> > +++ linux.new/drivers/block/pktcdvd.c 2007-11-30 13:24:08.000000000 +0800
> > @@ -117,8 +117,10 @@ static struct pktcdvd_kobj* pkt_kobj_cre
> > 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;
>
> This looks wrong to me. AFAICT the only thing that can fail
> kobject_register() is kobject_add() and it cleans up after itself. Am
> I missing something here?
Hi,
the kobject reference is get in kobject_init, and then kobject_add, if
kobject_add fail, it will only cleanup the reference got by itsself.
This topic is discussed in:
http://lkml.org/lkml/2007/11/30/9
Regards
dave
>
> Pekka
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]