public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/video/*: use kmemdup()
@ 2006-10-29 19:58 Alexey Dobriyan
  2006-10-30  9:45 ` Rolf Eike Beer
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2006-10-29 19:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Eric Sesterhenn

From: Eric Sesterhenn <snakebyte@gmx.de>

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 drivers/video/aty/radeon_monitor.c  |    3 +--
 drivers/video/i810/i810-i2c.c       |    4 +---
 drivers/video/intelfb/intelfbdrv.c  |    3 +--
 drivers/video/nvidia/nv_i2c.c       |    7 ++-----
 drivers/video/nvidia/nv_of.c        |    3 +--
 drivers/video/savage/savagefb-i2c.c |    7 ++-----
 6 files changed, 8 insertions(+), 19 deletions(-)

--- a/drivers/video/aty/radeon_monitor.c
+++ b/drivers/video/aty/radeon_monitor.c
@@ -104,10 +104,9 @@ static int __devinit radeon_parse_montyp
 	if (pedid == NULL)
 		return mt;
 
-	tmp = (u8 *)kmalloc(EDID_LENGTH, GFP_KERNEL);
+	tmp = (u8 *)kmemdup(pedid, EDID_LENGTH, GFP_KERNEL);
 	if (!tmp)
 		return mt;
-	memcpy(tmp, pedid, EDID_LENGTH);
 	*out_EDID = tmp;
 	return mt;
 }
--- a/drivers/video/i810/i810-i2c.c
+++ b/drivers/video/i810/i810-i2c.c
@@ -162,9 +162,7 @@ int i810_probe_i2c_connector(struct fb_i
 
 		if (e != NULL) {
 			DPRINTK("i810-i2c: Getting EDID from BIOS\n");
-			edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-			if (edid)
-				memcpy(edid, e, EDID_LENGTH);
+			edid = kmemdup(e, EDID_LENGTH, GFP_KERNEL);
 		}
 	}
 
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -1058,10 +1058,9 @@ intelfb_init_var(struct intelfb_info *di
 		u8 *edid_d = NULL;
 
 		if (edid_s) {
-			edid_d = kmalloc(EDID_LENGTH, GFP_KERNEL);
+			edid_d = kmemdup(edid_s, EDID_LENGTH, GFP_KERNEL);
 
 			if (edid_d) {
-				memcpy(edid_d, edid_s, EDID_LENGTH);
 				fb_edid_to_monspecs(edid_d,
 						    &dinfo->info->monspecs);
 				kfree(edid_d);
--- a/drivers/video/nvidia/nv_i2c.c
+++ b/drivers/video/nvidia/nv_i2c.c
@@ -210,11 +210,8 @@ int nvidia_probe_i2c_connector(struct fb
 		/* try to get from firmware */
 		const u8 *e = fb_firmware_edid(info->device);
 
-		if (e != NULL) {
-			edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-			if (edid)
-				memcpy(edid, e, EDID_LENGTH);
-		}
+		if (e != NULL)
+			edid = kmemdup(e, EDID_LENGTH, GFP_KERNEL);
 	}
 
 	*out_edid = edid;
--- a/drivers/video/nvidia/nv_of.c
+++ b/drivers/video/nvidia/nv_of.c
@@ -72,10 +72,9 @@ int nvidia_probe_of_connector(struct fb_
 		}
 	}
 	if (pedid) {
-		*out_edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
+		*out_edid = kmemdup(pedid, EDID_LENGTH, GFP_KERNEL);
 		if (*out_edid == NULL)
 			return -1;
-		memcpy(*out_edid, pedid, EDID_LENGTH);
 		printk(KERN_DEBUG "nvidiafb: Found OF EDID for head %d\n", conn);
 		return 0;
 	}
--- a/drivers/video/savage/savagefb-i2c.c
+++ b/drivers/video/savage/savagefb-i2c.c
@@ -227,11 +227,8 @@ int savagefb_probe_i2c_connector(struct 
 		/* try to get from firmware */
 		const u8 *e = fb_firmware_edid(info->device);
 
-		if (e) {
-			edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-			if (edid)
-				memcpy(edid, e, EDID_LENGTH);
-		}
+		if (e)
+			edid = kmemdup(e, EDID_LENGTH, GFP_KERNEL);
 	}
 
 	*out_edid = edid;


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

* Re: [PATCH] drivers/video/*: use kmemdup()
  2006-10-29 19:58 [PATCH] drivers/video/*: use kmemdup() Alexey Dobriyan
@ 2006-10-30  9:45 ` Rolf Eike Beer
  0 siblings, 0 replies; 2+ messages in thread
From: Rolf Eike Beer @ 2006-10-30  9:45 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: Andrew Morton, linux-kernel, Eric Sesterhenn

[-- Attachment #1: Type: text/plain, Size: 866 bytes --]

Alexey Dobriyan wrote:
> From: Eric Sesterhenn <snakebyte@gmx.de>
>
> Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
>
>  drivers/video/aty/radeon_monitor.c  |    3 +--
>  drivers/video/i810/i810-i2c.c       |    4 +---
>  drivers/video/intelfb/intelfbdrv.c  |    3 +--
>  drivers/video/nvidia/nv_i2c.c       |    7 ++-----
>  drivers/video/nvidia/nv_of.c        |    3 +--
>  drivers/video/savage/savagefb-i2c.c |    7 ++-----
>  6 files changed, 8 insertions(+), 19 deletions(-)
>
> --- a/drivers/video/aty/radeon_monitor.c
> +++ b/drivers/video/aty/radeon_monitor.c
> @@ -104,10 +104,9 @@ static int __devinit radeon_parse_montyp
>  	if (pedid == NULL)
>  		return mt;
>
> -	tmp = (u8 *)kmalloc(EDID_LENGTH, GFP_KERNEL);
> +	tmp = (u8 *)kmemdup(pedid, EDID_LENGTH, GFP_KERNEL);

No cast here.

Eike

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2006-10-30  9:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-29 19:58 [PATCH] drivers/video/*: use kmemdup() Alexey Dobriyan
2006-10-30  9:45 ` Rolf Eike Beer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox