aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/usx2y/us122l.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/usx2y/us122l.c')
-rw-r--r--sound/usb/usx2y/us122l.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 98276aafefe6..a5aae9d67f31 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -349,14 +349,10 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
349 if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) 349 if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS)
350 return -ENOTTY; 350 return -ENOTTY;
351 351
352 cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 352 cfg = memdup_user((void *)arg, sizeof(*cfg));
353 if (!cfg) 353 if (IS_ERR(cfg))
354 return -ENOMEM; 354 return PTR_ERR(cfg);
355 355
356 if (copy_from_user(cfg, (void *)arg, sizeof(*cfg))) {
357 err = -EFAULT;
358 goto free;
359 }
360 if (cfg->version != USB_STREAM_INTERFACE_VERSION) { 356 if (cfg->version != USB_STREAM_INTERFACE_VERSION) {
361 err = -ENXIO; 357 err = -ENXIO;
362 goto free; 358 goto free;
@@ -478,6 +474,14 @@ static bool us122l_create_card(struct snd_card *card)
478 return true; 474 return true;
479} 475}
480 476
477static void snd_us122l_free(struct snd_card *card)
478{
479 struct us122l *us122l = US122L(card);
480 int index = us122l->chip.index;
481 if (index >= 0 && index < SNDRV_CARDS)
482 snd_us122l_card_used[index] = 0;
483}
484
481static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) 485static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
482{ 486{
483 int dev; 487 int dev;
@@ -494,7 +498,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
494 if (err < 0) 498 if (err < 0)
495 return err; 499 return err;
496 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; 500 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
497 501 card->private_free = snd_us122l_free;
498 US122L(card)->chip.dev = device; 502 US122L(card)->chip.dev = device;
499 US122L(card)->chip.card = card; 503 US122L(card)->chip.card = card;
500 mutex_init(&US122L(card)->mutex); 504 mutex_init(&US122L(card)->mutex);
@@ -588,7 +592,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
588 } 592 }
589 593
590 usb_put_intf(intf); 594 usb_put_intf(intf);
591 usb_put_dev(US122L(card)->chip.dev); 595 usb_put_dev(us122l->chip.dev);
592 596
593 while (atomic_read(&us122l->mmap_count)) 597 while (atomic_read(&us122l->mmap_count))
594 msleep(500); 598 msleep(500);