Skip to contentSkip to conversation

staging: bcm2835-audio: bcm2835-vchiq: Replace kmalloc with kzalloc

PATCH In review sayli karnik 2 participants 2 messages Mar 10, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: bcm2835-audio: bcm2835-vchiq: Replace kmalloc with kzalloc

This patch replaces kmalloc and memset with kzalloc. Done using coccinelle:
@@
type T, T2;
expression x;
expression E1,E2;
statement S;
@@

- x = (T)kmalloc(E1,E2);
+ x = kzalloc(E1,E2);
if ((x==NULL) || ...) S
- memset((T2)x,0,E1);

---
 drivers/staging/bcm2835-audio/bcm2835-vchiq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/bcm2835-audio/bcm2835-vchiq.c +1 -2
index fa23a13..a117b05 100644
@@ -289,11 +289,10 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance,
 		return NULL;
 	}
 	/* Allocate memory for this instance */
-	instance = kmalloc(sizeof(*instance), GFP_KERNEL);
+	instance = kzalloc(sizeof(*instance), GFP_KERNEL);
 	if (!instance)
 		return NULL;
 
-	memset(instance, 0, sizeof(*instance));
 	instance->num_connections = num_connections;
 
 	/* Create a lock for exclusive, serialized VCHI connection access */
Signature · 1 line
2.7.4
#1 lore raw
Quoted 9 lines · sayli karnik

This patch replaces kmalloc and memset with kzalloc. Done using coccinelle:
@@
type T, T2;
expression x;
expression E1,E2;
statement S;
@@

Quoted 8 lines

- x = (T)kmalloc(E1,E2);
+ x = kzalloc(E1,E2);
if ((x==NULL) || ...) S
- memset((T2)x,0,E1);

---
 drivers/staging/bcm2835-audio/bcm2835-vchiq.c | 3 +--

The file has not existed for a few days now. It is in another directory. I think that there has already been a patch on this issue, but you can check if it is still relevant.

As Alison suggested, it is good to update your kernel every time you start to work. There are a lot of patches flying around on this code at the moment.

julia

Quoted 29 lines
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/bcm2835-audio/bcm2835-vchiq.c +1 -3
index fa23a13..a117b05 100644
@@ -289,11 +289,10 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance,
 		return NULL;
 	}
 	/* Allocate memory for this instance */
-	instance = kmalloc(sizeof(*instance), GFP_KERNEL);
+	instance = kzalloc(sizeof(*instance), GFP_KERNEL);
 	if (!instance)
 		return NULL;
 
-	memset(instance, 0, sizeof(*instance));
 	instance->num_connections = num_connections;
 
 	/* Create a lock for exclusive, serialized VCHI connection access */
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170310064211.GA7443%40sayli-HP-15-Notebook-PC.
For more options, visit https://groups.google.com/d/optout.