mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jakob Bornecrantz <jakob@vmware.com>
To: Thomas Meyer <thomas@m3y3r.de>
Cc: airlied@linux.ie, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vmwgfx: Use kcalloc instead of kzalloc to allocate array
Date: Mon, 5 Dec 2011 02:06:46 -0800 (PST)	[thread overview]
Message-ID: <855788278.405280.1323079606487.JavaMail.root@zimbra-prod-mbox-2.vmware.com> (raw)
In-Reply-To: <1322600880.1534.299.camel@localhost.localdomain>

Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>

----- Original Message -----
> The advantage of kcalloc is, that will prevent integer overflows
> which could result from the multiplication of number of elements
> and size and it is also a bit nicer to read.
> 
> The semantic patch that makes this change is available
> in https://lkml.org/lkml/2011/11/25/107
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
> 
> diff -u -p a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c 2011-11-13
> 11:07:24.343455126 +0100
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c 2011-11-28
> 19:50:07.413502824 +0100
> @@ -140,7 +140,7 @@ int vmw_present_ioctl(struct drm_device
>  		goto out_clips;
>  	}
>  
> -	clips = kzalloc(num_clips * sizeof(*clips), GFP_KERNEL);
> +	clips = kcalloc(num_clips, sizeof(*clips), GFP_KERNEL);
>  	if (clips == NULL) {
>  		DRM_ERROR("Failed to allocate clip rect list.\n");
>  		ret = -ENOMEM;
> @@ -232,7 +232,7 @@ int vmw_present_readback_ioctl(struct dr
>  		goto out_clips;
>  	}
>  
> -	clips = kzalloc(num_clips * sizeof(*clips), GFP_KERNEL);
> +	clips = kcalloc(num_clips, sizeof(*clips), GFP_KERNEL);
>  	if (clips == NULL) {
>  		DRM_ERROR("Failed to allocate clip rect list.\n");
>  		ret = -ENOMEM;

      reply	other threads:[~2011-12-05 10:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-29 21:08 Thomas Meyer
2011-12-05 10:06 ` Jakob Bornecrantz [this message]

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=855788278.405280.1323079606487.JavaMail.root@zimbra-prod-mbox-2.vmware.com \
    --to=jakob@vmware.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas@m3y3r.de \
    /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®