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] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 29 Nov 2007 13:53:04 -0800
From:	Greg KH <greg@...ah.com>
To:	Cornelia Huck <cornelia.huck@...ibm.com>
Cc:	Kay Sievers <kay.sievers@...y.org>,
	Alan Stern <stern@...land.harvard.edu>,
	Kernel development list <linux-kernel@...r.kernel.org>,
	Jonathan Corbet <corbet@....net>,
	Randy Dunlap <randy.dunlap@...cle.com>
Subject: kobject_init rewrite

On Thu, Nov 29, 2007 at 05:21:34PM +0100, Cornelia Huck wrote:
> Kay Sievers <kay.sievers@...y.org> wrote:
> >   int kobject_init(struct kobject *kobj, struct kobj_type *type, const char *fmt, ...)
> 
> Agreed. Better don't hide too much.


Ok, how about this function.  If it errors out, it is free to just call
kfree() on the kobject.  Seems simple enough to me, any objections?  If
not, I'll go through and fix up the whole tree...

thanks,

greg k-h

-----------------

/**
 * kobject_init - initialize a kobject structure
 * @kobj: pointer to the kobject to initialize
 * @ktype: pointer to the ktype for this kobject.
 * @fmt: the name of the kobject
 *
 * This function will properly initialize a kobject such that it can then
 * be passed to the kobject_add() call.
 *
 * If the function returns an error, the memory allocated by the kobject
 * can be safely freed, no other functions need to be called.
 */
int kobject_init(struct kobject *kobj, struct kobj_type *ktype, const char *fmt, ...)
{
	va_list args;
	int retval;

	if (!kobj)
		return -EINVAL;

	if (!ktype)
		return -EINVAL;

	WARN_ON(atomic_read(&kobj->kref.refcount));
	kref_init(&kobj->kref);
	INIT_LIST_HEAD(&kobj->entry);
	kobj->ktype = ktype;

	va_start(args, fmt);
	retval = kobject_set_name_vargs(kobj, fmt, args);
	va_end(args);

	return retval;
}

-
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