All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aishwarya Pant <aishpant@gmail.com>
To: Stephen Warren <swarren@wwwdotorg.org>,
	Lee Jones <lee@kernel.org>, Eric Anholt <eric@anholt.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com
Cc: outreachy-kernel@googlegroups.com
Subject: [PATCH v2] staging: bcm2835-camera: replace kmalloc with kzalloc
Date: Mon, 6 Mar 2017 12:51:36 +0530	[thread overview]
Message-ID: <20170306072136.GA19014@aishwarya> (raw)

This patch replaces two instances of kmalloc and memset with kzalloc
and refactors function get_msg_context(..)

Signed-off-by: Aishwarya Pant <aishpant@gmail.com>

---
Changes in v2:
	- Return out of memory error number when kzalloc fails
	- Refactor get_msg_context

 drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
index 0f96ac8..87d7681 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
@@ -166,13 +166,9 @@ struct vchiq_mmal_instance {
 static struct mmal_msg_context *get_msg_context(struct vchiq_mmal_instance
 						*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));
+	/* todo: should this be allocated from a pool to avoid kzalloc */
+	return kzalloc(sizeof(*msg_context), GFP_KERNEL);
 
-	return msg_context;
 }
 
 static void release_msg_context(struct mmal_msg_context *msg_context)
@@ -1881,8 +1877,9 @@ 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);
+	if (!instance)
+		return -ENOMEM;
 
 	mutex_init(&instance->vchiq_mutex);
 	mutex_init(&instance->bulk_mutex);
-- 
2.7.4



             reply	other threads:[~2017-03-06  7:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-06  7:21 Aishwarya Pant [this message]
2017-03-06 12:53 ` [Outreachy kernel] [PATCH v2] staging: bcm2835-camera: replace kmalloc with kzalloc Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170306072136.GA19014@aishwarya \
    --to=aishpant@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=eric@anholt.net \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee@kernel.org \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.com \
    --cc=swarren@wwwdotorg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.