Re: [PATCH] drivers: gpu: drm: i915: Replaced calls to kmalloc & memcpy with kmemdup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2013-03-11 at 22:39 +0200, Alexandru Gheorghiu wrote:
> Replaced calls to kmalloc followed by memcpy with a single call to kmemdup.
> Also removed a now redundant if statement.
[]
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
[]
> @@ -2335,11 +2335,8 @@ intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
>  			return NULL;
>  
>  		size = (intel_connector->edid->extensions + 1) * EDID_LENGTH;
> -		edid = kmalloc(size, GFP_KERNEL);
> -		if (!edid)
> -			return NULL;
> +		edid = kmemdup(intel_connector->edid, size, GFP_KERNEL);
>  
> -		memcpy(edid, intel_connector->edid, size);
>  		return edid;
>  	}
>  

Might as well get rid of the stack variable edid altogether.
Maybe get rid of size too and use:

	if (intel_connector->edid) {
		/* invalid edid */
		if (IS_ERR(intel_connector->edid))
			return NULL;

		return kmemdup(intel_connector->edid,
			       (intel_connector->edid->extensions + 1) * EDID_LENGTH,
			       GFP_KERNEL);
	}


_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux