mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Rakib Mullick <rakib.mullick@gmail.com>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] drivers: Use kzalloc instead of 'kmalloc+memset', where possible.
Date: Mon, 23 May 2011 10:51:25 -0700	[thread overview]
Message-ID: <1306173085.8687.38.camel@Joe-Laptop> (raw)
In-Reply-To: <1306172407.8198.3.camel@localhost.localdomain>

On Mon, 2011-05-23 at 23:40 +0600, Rakib Mullick wrote:
> Following patch removes the uses of 'kmalloc+memset' from various
> drivers subsystems, which is replaced by kzalloc. kzalloc take care of
> setting allocated memory with null, so it helps to get rid from using
> memset.
> diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
[]
> -	entry->pagelist = kmalloc(pages * sizeof(*entry->pagelist), GFP_KERNEL);
> +	entry->pagelist = kzalloc(pages * sizeof(*entry->pagelist), GFP_KERNEL);

Perhaps it's better to use:

	entry->pagelist =  kcalloc(pages, sizeof(*entry->pagelist), GFP_KERNEL);

> -	entry->busaddr = kmalloc(pages * sizeof(*entry->busaddr), GFP_KERNEL);
> +	entry->busaddr = kzalloc(pages * sizeof(*entry->busaddr), GFP_KERNEL);

here too.


  reply	other threads:[~2011-05-23 17:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-23 17:40 Rakib Mullick
2011-05-23 17:51 ` Joe Perches [this message]
2011-05-24 16:59   ` Rakib Mullick
2011-05-24 17:09     ` Joe Perches

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=1306173085.8687.38.camel@Joe-Laptop \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rakib.mullick@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®