Skip to contentSkip to conversation

staging: bcm2835-camera: replace kmalloc with kzalloc

PATCH Superseded Aishwarya Pant 2 participants 2 messages Mar 6, 2017

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: bcm2835-camera: replace kmalloc with kzalloc

Replace two instances of kmalloc and memset with kzalloc in bcm2835-camera

---
 drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +2 -4
index 0f96ac8..cb8d129 100644
@@ -169,8 +169,7 @@ static struct mmal_msg_context *get_msg_context(struct vchiq_mmal_instance
 	struct mmal_msg_context *msg_context;
 
 	/* todo: should this be allocated from a pool to avoid kmalloc */
-	msg_context = kmalloc(sizeof(*msg_context), GFP_KERNEL);
-	memset(msg_context, 0, sizeof(*msg_context));
+	msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
 
 	return msg_context;
 }
@@ -1881,8 +1880,7 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
 		return -EIO;
 	}
 
-	instance = kmalloc(sizeof(*instance), GFP_KERNEL);
-	memset(instance, 0, sizeof(*instance));
+	instance = kzalloc(sizeof(*instance), GFP_KERNEL);
 
 	mutex_init(&instance->vchiq_mutex);
 	mutex_init(&instance->bulk_mutex);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 13 lines · Aishwarya Pant

Replace two instances of kmalloc and memset with kzalloc in bcm2835-camera

---
 drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +0 -0
index 0f96ac8..cb8d129 100644

drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c static struct mmal_msg_context *get_msg_context(struct vchiq_mmal_instance · line 171

Quoted 3 lines
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +0 -0
@@ -169,8 +169,7 @@ static struct mmal_msg_context *get_msg_context(struct vchiq_mmal_instance
 	struct mmal_msg_context *msg_context;
 
 	/* todo: should this be allocated from a pool to avoid kmalloc */

You could update the comment too.

drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c static struct mmal_msg_context *get_msg_context(struct vchiq_mmal_instance · line 174

Quoted 5 lines
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +1 -2
-	msg_context = kmalloc(sizeof(*msg_context), GFP_KERNEL);
-	memset(msg_context, 0, sizeof(*msg_context));
+	msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
 
 	return msg_context;

This function could be just one line.

drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) · line 1883

Quoted 8 lines
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +1 -2
 }
@@ -1881,8 +1880,7 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
 		return -EIO;
 	}
 
-	instance = kmalloc(sizeof(*instance), GFP_KERNEL);
-	memset(instance, 0, sizeof(*instance));
+	instance = kzalloc(sizeof(*instance), GFP_KERNEL);

This code should detect the case where the result of kzalloc is NULL and return -ENOMEM.

julia

Quoted 12 lines
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +0 -1
 	mutex_init(&instance->vchiq_mutex);
 	mutex_init(&instance->bulk_mutex);
--

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/20170306062310.GA17005%40aishwarya.
For more options, visit https://groups.google.com/d/optout.