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

Alexandru Gheorghiu gheorghiuandru at gmail.com
Mon Mar 11 12:30:40 PDT 2013


Replaced calls to kmalloc followed by memcpy with a single call to kmemdup.
This patch was found using coccinelle.

Signed-off-by: Alexandru Gheorghiu <gheorghiuandru at gmail.com>
---
 drivers/gpu/drm/i915/intel_dp.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index f61cb79..a3fdd65 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -2335,11 +2335,10 @@ 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);
+		edid = kmemdup(intel_connector->edid, size, GFP_KERNEL);
 		if (!edid)
 			return NULL;
 
-		memcpy(edid, intel_connector->edid, size);
 		return edid;
 	}
 
-- 
1.7.9.5



More information about the dri-devel mailing list