diff options
author | Julia Lawall <julia@diku.dk> | 2010-05-15 17:17:40 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-05-18 01:55:55 -0400 |
commit | f405a1ab2bf316b1969fc5355891e5dff4e1a54c (patch) | |
tree | 30bf6908ec23fa0695b111c672d7f3abc6f4ceaf /drivers/gpu/drm/radeon/radeon_bios.c | |
parent | ca117d6df95a8f809d37d74c2d715ec3c8c3a4ed (diff) |
drivers/gpu/drm: Use kmemdup
Use kmemdup when some other buffer is immediately copied into the
allocated region.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression from,to,size,flag;
statement S;
@@
- to = \(kmalloc\|kzalloc\)(size,flag);
+ to = kmemdup(from,size,flag);
if (to==NULL || ...) S
- memcpy(to, from, size);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_bios.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_bios.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c index 8ad71f701316..fbba938f8048 100644 --- a/drivers/gpu/drm/radeon/radeon_bios.c +++ b/drivers/gpu/drm/radeon/radeon_bios.c | |||
@@ -85,12 +85,11 @@ static bool radeon_read_bios(struct radeon_device *rdev) | |||
85 | pci_unmap_rom(rdev->pdev, bios); | 85 | pci_unmap_rom(rdev->pdev, bios); |
86 | return false; | 86 | return false; |
87 | } | 87 | } |
88 | rdev->bios = kmalloc(size, GFP_KERNEL); | 88 | rdev->bios = kmemdup(bios, size, GFP_KERNEL); |
89 | if (rdev->bios == NULL) { | 89 | if (rdev->bios == NULL) { |
90 | pci_unmap_rom(rdev->pdev, bios); | 90 | pci_unmap_rom(rdev->pdev, bios); |
91 | return false; | 91 | return false; |
92 | } | 92 | } |
93 | memcpy(rdev->bios, bios, size); | ||
94 | pci_unmap_rom(rdev->pdev, bios); | 93 | pci_unmap_rom(rdev->pdev, bios); |
95 | return true; | 94 | return true; |
96 | } | 95 | } |