Re: [PATCH] use kzalloc instead of malloc+memset

From: Jiri Slaby
Date: Tue Sep 13 2005 - 06:30:13 EST


Denis Vlasenko napsal(a):

On Tuesday 13 September 2005 01:47, Lion Vollnhals wrote:


On Tuesday 13 September 2005 00:10, Lion Vollnhals wrote:


This patch against 2.6.13-mm3 replaces malloc and memset with kzalloc in
drivers/base/class.c .

The following patch converts further kmalllocs and memsets in drivers/base/* to kzallocs.

Please apply.

Signed-off-by: Lion Vollnhals <webmaster@xxxxxxxxxx>





diff -Nurp 2.6.13-mm3/drivers/base/platform.c 2.6.13-mm3-changed/drivers/base/platform.c
--- 2.6.13-mm3/drivers/base/platform.c 2005-09-12 23:42:47.000000000 +0200
+++ 2.6.13-mm3-changed/drivers/base/platform.c 2005-09-13 00:23:43.000000000 +0200
@@ -225,13 +225,12 @@ struct platform_device *platform_device_
struct platform_object *pobj;
int retval;

- pobj = kmalloc(sizeof(struct platform_object) + sizeof(struct resource) * num, GFP_KERNEL);
+ pobj = kzalloc(sizeof(struct platform_object) + sizeof(struct resource) * num, GFP_KERNEL);
if (!pobj) {
retval = -ENOMEM;
goto error;
}

- memset(pobj, 0, sizeof(*pobj));



Was this a bug or did you just introduced one?


Yes, this was a bug.

--
Jiri Slaby www.fi.muni.cz/~xslaby
~\-/~ jirislaby@xxxxxxxxx ~\-/~
241B347EC88228DE51EE A49C4A73A25004CB2A10

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/