aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2006-10-01 02:27:21 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-01 03:39:19 -0400
commit52978be636374c4bfb61220b37fa12f55a071c46 (patch)
tree36444be7bdbc0cdd99d903c0ad87316c93427517
parent1a2f67b459bb7846d4a15924face63eb2683acc2 (diff)
[PATCH] kmemdup: some users
Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--arch/i386/kernel/process.c5
-rw-r--r--fs/posix_acl.c6
-rw-r--r--mm/mempolicy.c3
-rw-r--r--net/rxrpc/transport.c3
-rw-r--r--sound/pci/echoaudio/layla24_dsp.c4
-rw-r--r--sound/usb/usbaudio.c11
-rw-r--r--sound/usb/usbmidi.c3
7 files changed, 13 insertions, 22 deletions
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index 8c190ca7ae44..96cd0232e1e0 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -425,13 +425,12 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
425 425
426 tsk = current; 426 tsk = current;
427 if (unlikely(test_tsk_thread_flag(tsk, TIF_IO_BITMAP))) { 427 if (unlikely(test_tsk_thread_flag(tsk, TIF_IO_BITMAP))) {
428 p->thread.io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL); 428 p->thread.io_bitmap_ptr = kmemdup(tsk->thread.io_bitmap_ptr,
429 IO_BITMAP_BYTES, GFP_KERNEL);
429 if (!p->thread.io_bitmap_ptr) { 430 if (!p->thread.io_bitmap_ptr) {
430 p->thread.io_bitmap_max = 0; 431 p->thread.io_bitmap_max = 0;
431 return -ENOMEM; 432 return -ENOMEM;
432 } 433 }
433 memcpy(p->thread.io_bitmap_ptr, tsk->thread.io_bitmap_ptr,
434 IO_BITMAP_BYTES);
435 set_tsk_thread_flag(p, TIF_IO_BITMAP); 434 set_tsk_thread_flag(p, TIF_IO_BITMAP);
436 } 435 }
437 436
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 6c8dcf7613fd..aec931e09973 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -58,11 +58,9 @@ posix_acl_clone(const struct posix_acl *acl, gfp_t flags)
58 if (acl) { 58 if (acl) {
59 int size = sizeof(struct posix_acl) + acl->a_count * 59 int size = sizeof(struct posix_acl) + acl->a_count *
60 sizeof(struct posix_acl_entry); 60 sizeof(struct posix_acl_entry);
61 clone = kmalloc(size, flags); 61 clone = kmemdup(acl, size, flags);
62 if (clone) { 62 if (clone)
63 memcpy(clone, acl, size);
64 atomic_set(&clone->a_refcount, 1); 63 atomic_set(&clone->a_refcount, 1);
65 }
66 } 64 }
67 return clone; 65 return clone;
68} 66}
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index cf18f0942553..25788b1b7fcf 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1324,12 +1324,11 @@ struct mempolicy *__mpol_copy(struct mempolicy *old)
1324 atomic_set(&new->refcnt, 1); 1324 atomic_set(&new->refcnt, 1);
1325 if (new->policy == MPOL_BIND) { 1325 if (new->policy == MPOL_BIND) {
1326 int sz = ksize(old->v.zonelist); 1326 int sz = ksize(old->v.zonelist);
1327 new->v.zonelist = kmalloc(sz, SLAB_KERNEL); 1327 new->v.zonelist = kmemdup(old->v.zonelist, sz, SLAB_KERNEL);
1328 if (!new->v.zonelist) { 1328 if (!new->v.zonelist) {
1329 kmem_cache_free(policy_cache, new); 1329 kmem_cache_free(policy_cache, new);
1330 return ERR_PTR(-ENOMEM); 1330 return ERR_PTR(-ENOMEM);
1331 } 1331 }
1332 memcpy(new->v.zonelist, old->v.zonelist, sz);
1333 } 1332 }
1334 return new; 1333 return new;
1335} 1334}
diff --git a/net/rxrpc/transport.c b/net/rxrpc/transport.c
index 465efc86fccf..94b2e2fe6fdb 100644
--- a/net/rxrpc/transport.c
+++ b/net/rxrpc/transport.c
@@ -381,11 +381,10 @@ static int rxrpc_incoming_msg(struct rxrpc_transport *trans,
381 381
382 /* allocate a new message record */ 382 /* allocate a new message record */
383 ret = -ENOMEM; 383 ret = -ENOMEM;
384 msg = kmalloc(sizeof(struct rxrpc_message), GFP_KERNEL); 384 msg = kmemdup(jumbomsg, sizeof(struct rxrpc_message), GFP_KERNEL);
385 if (!msg) 385 if (!msg)
386 goto error; 386 goto error;
387 387
388 memcpy(msg, jumbomsg, sizeof(*msg));
389 list_add_tail(&msg->link, msgq); 388 list_add_tail(&msg->link, msgq);
390 389
391 /* adjust the jumbo packet */ 390 /* adjust the jumbo packet */
diff --git a/sound/pci/echoaudio/layla24_dsp.c b/sound/pci/echoaudio/layla24_dsp.c
index 7ec5b63d0dce..97e42e115147 100644
--- a/sound/pci/echoaudio/layla24_dsp.c
+++ b/sound/pci/echoaudio/layla24_dsp.c
@@ -302,11 +302,11 @@ static int switch_asic(struct echoaudio *chip, const struct firmware *asic)
302 302
303 /* Check to see if this is already loaded */ 303 /* Check to see if this is already loaded */
304 if (asic != chip->asic_code) { 304 if (asic != chip->asic_code) {
305 monitors = kmalloc(MONITOR_ARRAY_SIZE, GFP_KERNEL); 305 monitors = kmemdup(chip->comm_page->monitors,
306 MONITOR_ARRAY_SIZE, GFP_KERNEL);
306 if (! monitors) 307 if (! monitors)
307 return -ENOMEM; 308 return -ENOMEM;
308 309
309 memcpy(monitors, chip->comm_page->monitors, MONITOR_ARRAY_SIZE);
310 memset(chip->comm_page->monitors, ECHOGAIN_MUTED, 310 memset(chip->comm_page->monitors, ECHOGAIN_MUTED,
311 MONITOR_ARRAY_SIZE); 311 MONITOR_ARRAY_SIZE);
312 312
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 49248fa7aef4..a42acf6d7b68 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -2046,10 +2046,9 @@ int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
2046 void *buf = NULL; 2046 void *buf = NULL;
2047 2047
2048 if (size > 0) { 2048 if (size > 0) {
2049 buf = kmalloc(size, GFP_KERNEL); 2049 buf = kmemdup(data, size, GFP_KERNEL);
2050 if (!buf) 2050 if (!buf)
2051 return -ENOMEM; 2051 return -ENOMEM;
2052 memcpy(buf, data, size);
2053 } 2052 }
2054 err = usb_control_msg(dev, pipe, request, requesttype, 2053 err = usb_control_msg(dev, pipe, request, requesttype,
2055 value, index, buf, size, timeout); 2054 value, index, buf, size, timeout);
@@ -2846,12 +2845,11 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
2846 int stream, err; 2845 int stream, err;
2847 int *rate_table = NULL; 2846 int *rate_table = NULL;
2848 2847
2849 fp = kmalloc(sizeof(*fp), GFP_KERNEL); 2848 fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL);
2850 if (! fp) { 2849 if (! fp) {
2851 snd_printk(KERN_ERR "cannot malloc\n"); 2850 snd_printk(KERN_ERR "cannot memdup\n");
2852 return -ENOMEM; 2851 return -ENOMEM;
2853 } 2852 }
2854 memcpy(fp, quirk->data, sizeof(*fp));
2855 if (fp->nr_rates > 0) { 2853 if (fp->nr_rates > 0) {
2856 rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL); 2854 rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL);
2857 if (!rate_table) { 2855 if (!rate_table) {
@@ -3029,10 +3027,9 @@ static int create_ua1000_quirk(struct snd_usb_audio *chip,
3029 altsd->bNumEndpoints != 1) 3027 altsd->bNumEndpoints != 1)
3030 return -ENXIO; 3028 return -ENXIO;
3031 3029
3032 fp = kmalloc(sizeof(*fp), GFP_KERNEL); 3030 fp = kmemdup(&ua1000_format, sizeof(*fp), GFP_KERNEL);
3033 if (!fp) 3031 if (!fp)
3034 return -ENOMEM; 3032 return -ENOMEM;
3035 memcpy(fp, &ua1000_format, sizeof(*fp));
3036 3033
3037 fp->channels = alts->extra[4]; 3034 fp->channels = alts->extra[4];
3038 fp->iface = altsd->bInterfaceNumber; 3035 fp->iface = altsd->bInterfaceNumber;
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index abe29dadd979..0dcf78adb99a 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -323,10 +323,9 @@ static int send_bulk_static_data(struct snd_usb_midi_out_endpoint* ep,
323 const void *data, int len) 323 const void *data, int len)
324{ 324{
325 int err; 325 int err;
326 void *buf = kmalloc(len, GFP_KERNEL); 326 void *buf = kmemdup(data, len, GFP_KERNEL);
327 if (!buf) 327 if (!buf)
328 return -ENOMEM; 328 return -ENOMEM;
329 memcpy(buf, data, len);
330 dump_urb("sending", buf, len); 329 dump_urb("sending", buf, len);
331 err = usb_bulk_msg(ep->umidi->chip->dev, ep->urb->pipe, buf, len, 330 err = usb_bulk_msg(ep->umidi->chip->dev, ep->urb->pipe, buf, len,
332 NULL, 250); 331 NULL, 250);