All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: gpu: drm: exynos: Replaced kzalloc & memcpy with kmemdup
@ 2013-03-11 19:25 Alexandru Gheorghiu
  2013-03-12  2:08 ` 김승우
  2013-03-12  4:12 ` Inki Dae
  0 siblings, 2 replies; 3+ messages in thread
From: Alexandru Gheorghiu @ 2013-03-11 19:25 UTC (permalink / raw)
  To: Inki Dae
  Cc: Joonyoung Shim, Seung-Woo Kim, Kyungmin Park, David Airlie,
	dri-devel, linux-kernel, Alexandru Gheorghiu

Replaced calls to kzalloc followed by memcpy with call to kmemdup.
Patch found using coccinelle.

Signed-off-by: Alexandru Gheorghiu <gheorghiuandru@gmail.com>
---
 drivers/gpu/drm/exynos/exynos_drm_vidi.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index 13ccbd4..9504b0c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -117,13 +117,12 @@ static struct edid *vidi_get_edid(struct device *dev,
 	}
 
 	edid_len = (1 + ctx->raw_edid->extensions) * EDID_LENGTH;
-	edid = kzalloc(edid_len, GFP_KERNEL);
+	edid = kmemdup(ctx->raw_edid, edid_len, GFP_KERNEL);
 	if (!edid) {
 		DRM_DEBUG_KMS("failed to allocate edid\n");
 		return ERR_PTR(-ENOMEM);
 	}
 
-	memcpy(edid, ctx->raw_edid, edid_len);
 	return edid;
 }
 
@@ -563,12 +562,11 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
 			return -EINVAL;
 		}
 		edid_len = (1 + raw_edid->extensions) * EDID_LENGTH;
-		ctx->raw_edid = kzalloc(edid_len, GFP_KERNEL);
+		ctx->raw_edid = kmemdup(raw_edid, edid_len, GFP_KERNEL);
 		if (!ctx->raw_edid) {
 			DRM_DEBUG_KMS("failed to allocate raw_edid.\n");
 			return -ENOMEM;
 		}
-		memcpy(ctx->raw_edid, raw_edid, edid_len);
 	} else {
 		/*
 		 * with connection = 0, free raw_edid
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers: gpu: drm: exynos: Replaced kzalloc & memcpy with kmemdup
  2013-03-11 19:25 [PATCH] drivers: gpu: drm: exynos: Replaced kzalloc & memcpy with kmemdup Alexandru Gheorghiu
@ 2013-03-12  2:08 ` 김승우
  2013-03-12  4:12 ` Inki Dae
  1 sibling, 0 replies; 3+ messages in thread
From: 김승우 @ 2013-03-12  2:08 UTC (permalink / raw)
  To: Alexandru Gheorghiu
  Cc: Inki Dae, linux-kernel, dri-devel, Kyungmin Park, sw0312.kim

Good point.

Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>

On 2013년 03월 12일 04:25, Alexandru Gheorghiu wrote:
> Replaced calls to kzalloc followed by memcpy with call to kmemdup.
> Patch found using coccinelle.
> 
> Signed-off-by: Alexandru Gheorghiu <gheorghiuandru@gmail.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_vidi.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> index 13ccbd4..9504b0c 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> @@ -117,13 +117,12 @@ static struct edid *vidi_get_edid(struct device *dev,
>  	}
>  
>  	edid_len = (1 + ctx->raw_edid->extensions) * EDID_LENGTH;
> -	edid = kzalloc(edid_len, GFP_KERNEL);
> +	edid = kmemdup(ctx->raw_edid, edid_len, GFP_KERNEL);
>  	if (!edid) {
>  		DRM_DEBUG_KMS("failed to allocate edid\n");
>  		return ERR_PTR(-ENOMEM);
>  	}
>  
> -	memcpy(edid, ctx->raw_edid, edid_len);
>  	return edid;
>  }
>  
> @@ -563,12 +562,11 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
>  			return -EINVAL;
>  		}
>  		edid_len = (1 + raw_edid->extensions) * EDID_LENGTH;
> -		ctx->raw_edid = kzalloc(edid_len, GFP_KERNEL);
> +		ctx->raw_edid = kmemdup(raw_edid, edid_len, GFP_KERNEL);
>  		if (!ctx->raw_edid) {
>  			DRM_DEBUG_KMS("failed to allocate raw_edid.\n");
>  			return -ENOMEM;
>  		}
> -		memcpy(ctx->raw_edid, raw_edid, edid_len);
>  	} else {
>  		/*
>  		 * with connection = 0, free raw_edid
> 

-- 
Seung-Woo Kim
Samsung Software R&D Center
--


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers: gpu: drm: exynos: Replaced kzalloc & memcpy with kmemdup
  2013-03-11 19:25 [PATCH] drivers: gpu: drm: exynos: Replaced kzalloc & memcpy with kmemdup Alexandru Gheorghiu
  2013-03-12  2:08 ` 김승우
@ 2013-03-12  4:12 ` Inki Dae
  1 sibling, 0 replies; 3+ messages in thread
From: Inki Dae @ 2013-03-12  4:12 UTC (permalink / raw)
  To: Alexandru Gheorghiu; +Cc: Seung-Woo Kim, linux-kernel, dri-devel, Kyungmin Park

Applied.

Thanks,
Inki Dae

2013/3/12 Alexandru Gheorghiu <gheorghiuandru@gmail.com>:
> Replaced calls to kzalloc followed by memcpy with call to kmemdup.
> Patch found using coccinelle.
>
> Signed-off-by: Alexandru Gheorghiu <gheorghiuandru@gmail.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_vidi.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> index 13ccbd4..9504b0c 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
> @@ -117,13 +117,12 @@ static struct edid *vidi_get_edid(struct device *dev,
>         }
>
>         edid_len = (1 + ctx->raw_edid->extensions) * EDID_LENGTH;
> -       edid = kzalloc(edid_len, GFP_KERNEL);
> +       edid = kmemdup(ctx->raw_edid, edid_len, GFP_KERNEL);
>         if (!edid) {
>                 DRM_DEBUG_KMS("failed to allocate edid\n");
>                 return ERR_PTR(-ENOMEM);
>         }
>
> -       memcpy(edid, ctx->raw_edid, edid_len);
>         return edid;
>  }
>
> @@ -563,12 +562,11 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
>                         return -EINVAL;
>                 }
>                 edid_len = (1 + raw_edid->extensions) * EDID_LENGTH;
> -               ctx->raw_edid = kzalloc(edid_len, GFP_KERNEL);
> +               ctx->raw_edid = kmemdup(raw_edid, edid_len, GFP_KERNEL);
>                 if (!ctx->raw_edid) {
>                         DRM_DEBUG_KMS("failed to allocate raw_edid.\n");
>                         return -ENOMEM;
>                 }
> -               memcpy(ctx->raw_edid, raw_edid, edid_len);
>         } else {
>                 /*
>                  * with connection = 0, free raw_edid
> --
> 1.7.9.5
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-12  4:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-11 19:25 [PATCH] drivers: gpu: drm: exynos: Replaced kzalloc & memcpy with kmemdup Alexandru Gheorghiu
2013-03-12  2:08 ` 김승우
2013-03-12  4:12 ` Inki Dae

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.