From 52978be636374c4bfb61220b37fa12f55a071c46 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Sat, 30 Sep 2006 23:27:21 -0700 Subject: [PATCH] kmemdup: some users Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- sound/usb/usbaudio.c | 11 ++++------- sound/usb/usbmidi.c | 3 +-- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'sound/usb') 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, void *buf = NULL; if (size > 0) { - buf = kmalloc(size, GFP_KERNEL); + buf = kmemdup(data, size, GFP_KERNEL); if (!buf) return -ENOMEM; - memcpy(buf, data, size); } err = usb_control_msg(dev, pipe, request, requesttype, value, index, buf, size, timeout); @@ -2846,12 +2845,11 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip, int stream, err; int *rate_table = NULL; - fp = kmalloc(sizeof(*fp), GFP_KERNEL); + fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL); if (! fp) { - snd_printk(KERN_ERR "cannot malloc\n"); + snd_printk(KERN_ERR "cannot memdup\n"); return -ENOMEM; } - memcpy(fp, quirk->data, sizeof(*fp)); if (fp->nr_rates > 0) { rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL); if (!rate_table) { @@ -3029,10 +3027,9 @@ static int create_ua1000_quirk(struct snd_usb_audio *chip, altsd->bNumEndpoints != 1) return -ENXIO; - fp = kmalloc(sizeof(*fp), GFP_KERNEL); + fp = kmemdup(&ua1000_format, sizeof(*fp), GFP_KERNEL); if (!fp) return -ENOMEM; - memcpy(fp, &ua1000_format, sizeof(*fp)); fp->channels = alts->extra[4]; 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, const void *data, int len) { int err; - void *buf = kmalloc(len, GFP_KERNEL); + void *buf = kmemdup(data, len, GFP_KERNEL); if (!buf) return -ENOMEM; - memcpy(buf, data, len); dump_urb("sending", buf, len); err = usb_bulk_msg(ep->umidi->chip->dev, ep->urb->pipe, buf, len, NULL, 250); -- cgit v1.2.2