kobject_free_name() missing?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I think this function is missing:

void kobject_free_name(struct kobject * kobj)
{
	if (kobj->k_name && kobj->k_name != kobj->name)
		kfree(kobj->k_name);
}

Here is a sample session that demonstrates why:

struct kobject kobj;

kobject_init(&kobj);

err = kobject_set_name(&kobj, "long trailer...");  // My be kmalloc'ed
if (err)
	return err;

err = kobject_add(&kobj);
if (err) {
	kobject_free_name(&kobj);  // Free name, if kmalloc'ed
	return err;
}

kobject_free_name() makes it explicit to the user that she has to free the 
name.

/FAU


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux