[Intel-gfx] [PATCH 2/2] drm/i915/pmu: Use kcalloc instead of kzalloc

Ville Syrjälä ville.syrjala at linux.intel.com
Fri Jan 12 17:14:06 UTC 2018


On Fri, Jan 12, 2018 at 05:03:40PM +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> kcalloc is preffered for allocating arrays.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Suggested-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>

Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

> ---
>  drivers/gpu/drm/i915/i915_pmu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
> index 9be4f5201e41..065a28c713c4 100644
> --- a/drivers/gpu/drm/i915/i915_pmu.c
> +++ b/drivers/gpu/drm/i915/i915_pmu.c
> @@ -785,16 +785,16 @@ create_event_attributes(struct drm_i915_private *i915)
>  	}
>  
>  	/* Allocate attribute objects and table. */
> -	i915_attr = kzalloc(count * sizeof(*i915_attr), GFP_KERNEL);
> +	i915_attr = kcalloc(count, sizeof(*i915_attr), GFP_KERNEL);
>  	if (!i915_attr)
>  		goto err_alloc;
>  
> -	pmu_attr = kzalloc(count * sizeof(*pmu_attr), GFP_KERNEL);
> +	pmu_attr = kcalloc(count, sizeof(*pmu_attr), GFP_KERNEL);
>  	if (!pmu_attr)
>  		goto err_alloc;
>  
>  	/* Max one pointer of each attribute type plus a termination entry. */
> -	attr = kzalloc((count * 2 + 1) * sizeof(*attr), GFP_KERNEL);
> +	attr = kcalloc(count * 2 + 1, sizeof(*attr), GFP_KERNEL);
>  	if (!attr)
>  		goto err_alloc;
>  
> -- 
> 2.14.1

-- 
Ville Syrjälä
Intel OTC


More information about the Intel-gfx mailing list