Re: [STAGING] slicoss - use kzalloc

From: Lior Dotan
Date: Wed Nov 05 2008 - 04:27:40 EST


-------- Original Message --------
Subject: Re: [STAGING] slicoss - use kzalloc
From: Jiri Slaby <jirislaby@xxxxxxxxx>
To: Lior Dotan <liodot@xxxxxxxxx>
CC: gregkh@xxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, charrer@xxxxxxxxxxxxxx
Date: 11/05/2008 12:01 AM

On 11/04/2008 05:27 PM, Lior Dotan wrote:
This patch uses kzalloc() where applicable.

Signed-off-by: Lior Dotan <liodot@xxxxxxxxx>

/drivers/staging/slicoss/slicoss.c
=======================================
--- b/drivers/staging/slicoss/slicoss.c 2008-11-04 11:53:12.878116772 +0200
+++ a/drivers/staging/slicoss/slicoss.c 2008-11-04 12:08:40.800644774 +0200
@@ -2673,8 +2673,8 @@
staticÂintÂslic_card_init(structÂsliccar
#ifÂSLIC_DUMP_ENABLED
 ifÂ(!card->dumpbuffer)Â{
-Â Â card->dumpbufferÂ=Âkmalloc(DUMP_PAGE_SIZE,ÂGFP_ATOMIC);
+Â Â card->dumpbufferÂ=Âkzalloc(DUMP_PAGE_SIZE,ÂGFP_ATOMIC);
  ASSERT(card->dumpbuffer);
  ifÂ(card->dumpbufferÂ==ÂNULL)
@@ -2683,8 +2683,7 @@
staticÂintÂslic_card_init(structÂsliccar
 Â*ÂÂSmearÂtheÂsharedÂmemoryÂstructureÂandÂthenÂobtain
 Â*ÂÂtheÂPHYSICALÂaddressÂofÂthisÂstructure
 Â*/
-Â memset(card->dumpbuffer,Â0,ÂDUMP_PAGE_SIZE);


It's wrong, the function in called multiple times, the memset was called every
time, now it would be called only for the first time.


You are right, thanks. Here's a fixed version.


This patch uses kzalloc() where really applicable.

Signed-off-by: Lior Dotan <liodot@xxxxxxxxx> --- b/drivers/staging/slicoss/slicoss.c 2008-11-05 11:21:13.697789873 +0200
+++ a/drivers/staging/slicoss/slicoss.c 2008-11-05 11:24:00.768399196 +0200
@@ -2833,9 +2833,8 @@ static u32 slic_card_locate(struct adapt
}
if (!physcard) {
/* no structure allocated for this physical card yet */
- physcard = kmalloc(sizeof(struct physcard *), GFP_ATOMIC);
+ physcard = kzalloc(sizeof(struct physcard *), GFP_ATOMIC);
ASSERT(physcard);
- memset(physcard, 0, sizeof(struct physcard *));

DBG_MSG
("\n%s Allocate a PHYSICALcard:\n PHYSICAL_Card[%p]\n\