[patch] /lib/kobject.c

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

 



From: Christophe Jaillet <christophe.jaillet@xxxxxxxxxx>

Hi, here is a patch against /lib/kobject.c.

No need to allocate more memory than usefull.
Here, we only need 12 (strlen("DEVPATH_OLD=")) + 1 (\0) extra bytes. This
saves 2 bytes !!! and improve readability IMO.


Signed-off-by: Christophe Jaillet <christophe.jaillet@xxxxxxxxxx>

---

diff --git a/lib/kobject.c b/lib/kobject.c
index 0487d1f..958cc76 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -412,7 +412,7 @@ int kobject_rename(struct kobject *kobj, const char
*new_name)
   error = -ENOMEM;
   goto out;
  }
- devpath_string = kmalloc(strlen(devpath) + 15, GFP_KERNEL);
+ devpath_string = kmalloc(12 + strlen(devpath) + 1, GFP_KERNEL);
  if (!devpath_string) {
   error = -ENOMEM;
   goto out;



--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux