lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 4 Dec 2007 16:26:41 +0800
From:	Dave Young <hidave.darkstar@...il.com>
To:	Pekka J Enberg <penberg@...helsinki.fi>
Cc:	petero2@...ia.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] pktcdvd : add kobject_put when kobject register fails

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@...il.com> 
Reviewed-by: Pekka Enberg <penberg@...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;
 }
 /*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ