diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-04-09 21:44:31 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-04-14 06:39:46 -0400 |
commit | 336500f0305dc1552e8d01a60b409a7db781ca28 (patch) | |
tree | f1a2e149a517a3fff2af8d987404979e5c4b0cd7 /sound | |
parent | 85385c1551d509e9e377b7be07ea0e755fb2c3ce (diff) |
ALSA: sound/pci: use memdup_user()
Remove open-coded memdup_user().
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/emu10k1/emufx.c | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 191e1cd9997..4b302d86f5f 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c | |||
@@ -2493,24 +2493,17 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un | |||
2493 | case SNDRV_EMU10K1_IOCTL_CODE_POKE: | 2493 | case SNDRV_EMU10K1_IOCTL_CODE_POKE: |
2494 | if (!capable(CAP_SYS_ADMIN)) | 2494 | if (!capable(CAP_SYS_ADMIN)) |
2495 | return -EPERM; | 2495 | return -EPERM; |
2496 | icode = kmalloc(sizeof(*icode), GFP_KERNEL); | 2496 | |
2497 | if (icode == NULL) | 2497 | icode = memdup_user(argp, sizeof(*icode)); |
2498 | return -ENOMEM; | 2498 | if (IS_ERR(icode)) |
2499 | if (copy_from_user(icode, argp, sizeof(*icode))) { | 2499 | return PTR_ERR(icode); |
2500 | kfree(icode); | ||
2501 | return -EFAULT; | ||
2502 | } | ||
2503 | res = snd_emu10k1_icode_poke(emu, icode); | 2500 | res = snd_emu10k1_icode_poke(emu, icode); |
2504 | kfree(icode); | 2501 | kfree(icode); |
2505 | return res; | 2502 | return res; |
2506 | case SNDRV_EMU10K1_IOCTL_CODE_PEEK: | 2503 | case SNDRV_EMU10K1_IOCTL_CODE_PEEK: |
2507 | icode = kmalloc(sizeof(*icode), GFP_KERNEL); | 2504 | icode = memdup_user(argp, sizeof(*icode)); |
2508 | if (icode == NULL) | 2505 | if (IS_ERR(icode)) |
2509 | return -ENOMEM; | 2506 | return PTR_ERR(icode); |
2510 | if (copy_from_user(icode, argp, sizeof(*icode))) { | ||
2511 | kfree(icode); | ||
2512 | return -EFAULT; | ||
2513 | } | ||
2514 | res = snd_emu10k1_icode_peek(emu, icode); | 2507 | res = snd_emu10k1_icode_peek(emu, icode); |
2515 | if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) { | 2508 | if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) { |
2516 | kfree(icode); | 2509 | kfree(icode); |
@@ -2519,24 +2512,16 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un | |||
2519 | kfree(icode); | 2512 | kfree(icode); |
2520 | return res; | 2513 | return res; |
2521 | case SNDRV_EMU10K1_IOCTL_PCM_POKE: | 2514 | case SNDRV_EMU10K1_IOCTL_PCM_POKE: |
2522 | ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL); | 2515 | ipcm = memdup_user(argp, sizeof(*ipcm)); |
2523 | if (ipcm == NULL) | 2516 | if (IS_ERR(ipcm)) |
2524 | return -ENOMEM; | 2517 | return PTR_ERR(ipcm); |
2525 | if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { | ||
2526 | kfree(ipcm); | ||
2527 | return -EFAULT; | ||
2528 | } | ||
2529 | res = snd_emu10k1_ipcm_poke(emu, ipcm); | 2518 | res = snd_emu10k1_ipcm_poke(emu, ipcm); |
2530 | kfree(ipcm); | 2519 | kfree(ipcm); |
2531 | return res; | 2520 | return res; |
2532 | case SNDRV_EMU10K1_IOCTL_PCM_PEEK: | 2521 | case SNDRV_EMU10K1_IOCTL_PCM_PEEK: |
2533 | ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL); | 2522 | ipcm = memdup_user(argp, sizeof(*ipcm)); |
2534 | if (ipcm == NULL) | 2523 | if (IS_ERR(ipcm)) |
2535 | return -ENOMEM; | 2524 | return PTR_ERR(ipcm); |
2536 | if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { | ||
2537 | kfree(ipcm); | ||
2538 | return -EFAULT; | ||
2539 | } | ||
2540 | res = snd_emu10k1_ipcm_peek(emu, ipcm); | 2525 | res = snd_emu10k1_ipcm_peek(emu, ipcm); |
2541 | if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) { | 2526 | if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) { |
2542 | kfree(ipcm); | 2527 | kfree(ipcm); |