From: Dave Young <hidave.darkstar@gmail.com>
To: Pekka J Enberg <penberg@cs.helsinki.fi>
Cc: petero2@telia.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pktcdvd : add kobject_put when kobject register fails
Date: Tue, 4 Dec 2007 16:26:41 +0800 [thread overview]
Message-ID: <20071204082641.GA21746@darkstar.te-china.tietoenator.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0712041004250.20088@sbz-30.cs.Helsinki.FI>
On Tue, Dec 04, 2007 at 10:05:24AM +0200, Pekka J Enberg wrote:
> Hi Dave,
>
> On Tue, 4 Dec 2007, Dave Young wrote:
> > 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
>
> Ok, thanks! Please the explanation to the changelog too.
>
Ok, lets add some explanation.
------------------------------
kobject_put should be called when kobject register functioin 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>
---
drivers/block/pktcdvd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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;
+ }
return p;
}
/*
prev parent reply other threads:[~2007-12-04 8:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-04 1:31 [PATCH] pktcdvd : add kobject_put when kobject register fails Dave Young
2007-12-04 7:45 ` Pekka Enberg
2007-12-04 8:00 ` Dave Young
2007-12-04 8:05 ` Pekka J Enberg
2007-12-04 8:26 ` Dave Young [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071204082641.GA21746@darkstar.te-china.tietoenator.com \
--to=hidave.darkstar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
--cc=petero2@telia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).