Update of /cvsroot/alsa/alsa-kernel/core
In directory usw-pr-cvs1:/tmp/cvs-serv25655

Modified Files:
        pcm_native.c 
Log Message:
Reduced stack usage in readv/writev functions

Index: pcm_native.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/core/pcm_native.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- pcm_native.c        12 Oct 2002 15:37:15 -0000      1.31
+++ pcm_native.c        13 Oct 2002 13:07:19 -0000      1.32
@@ -2124,10 +2124,10 @@
                        return -EFAULT;
                if (copy_from_user(&xfern, _xfern, sizeof(xfern)))
                        return -EFAULT;
-               bufs = kmalloc(sizeof(void *) * 128, GFP_KERNEL);
+               bufs = kmalloc(sizeof(void *) * runtime->channels, GFP_KERNEL);
                if (bufs == NULL)
                        return -ENOMEM;
-               if (copy_from_user(bufs, xfern.bufs, sizeof(*bufs) * 
runtime->channels)) {
+               if (copy_from_user(bufs, xfern.bufs, sizeof(void *) * 
+runtime->channels)) {
                        kfree(bufs);
                        return -EFAULT;
                }
@@ -2199,10 +2199,10 @@
                        return -EFAULT;
                if (copy_from_user(&xfern, _xfern, sizeof(xfern)))
                        return -EFAULT;
-               bufs = kmalloc(sizeof(void *) * 128, GFP_KERNEL);
+               bufs = kmalloc(sizeof(void *) * runtime->channels, GFP_KERNEL);
                if (bufs == NULL)
                        return -ENOMEM;
-               if (copy_from_user(bufs, xfern.bufs, sizeof(*bufs) * 
runtime->channels)) {
+               if (copy_from_user(bufs, xfern.bufs, sizeof(void *) * 
+runtime->channels)) {
                        kfree(bufs);
                        return -EFAULT;
                }
@@ -2359,7 +2359,7 @@
        snd_pcm_runtime_t *runtime;
        snd_pcm_sframes_t result;
        unsigned long i;
-       void *bufs[128];
+       void *bufs;
        snd_pcm_uframes_t frames;
 
        pcm_file = snd_magic_cast(snd_pcm_file_t, file->private_data, return -ENXIO);
@@ -2368,16 +2368,20 @@
        runtime = substream->runtime;
        if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
                return -EBADFD;
-       if (count > 128 || count != runtime->channels)
+       if (count > 1024 || count != runtime->channels)
                return -EINVAL;
        if (!frame_aligned(runtime, _vector->iov_len))
                return -EINVAL;
        frames = bytes_to_samples(runtime, _vector->iov_len);
+       bufs = kmalloc(sizeof(void *) * count, GFP_KERNEL);
+       if (bufs == NULL)
+               return -ENOMEM;
        for (i = 0; i < count; ++i)
                bufs[i] = _vector[i].iov_base;
        result = snd_pcm_lib_readv(substream, bufs, frames);
        if (result > 0)
                result = frames_to_bytes(runtime, result);
+       kfree(bufs);
        return result;
 }
 
@@ -2389,7 +2393,7 @@
        snd_pcm_runtime_t *runtime;
        snd_pcm_sframes_t result;
        unsigned long i;
-       void *bufs[128];
+       void *bufs;
        snd_pcm_uframes_t frames;
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
@@ -2409,11 +2413,15 @@
                goto end;
        }
        frames = bytes_to_samples(runtime, _vector->iov_len);
+       bufs = kcalloc(sizeof(void *) * count, GFP_KERNEL);
+       if (bufs == NULL)
+               return -ENOMEM;
        for (i = 0; i < count; ++i)
                bufs[i] = _vector[i].iov_base;
        result = snd_pcm_lib_writev(substream, bufs, frames);
        if (result > 0)
                result = frames_to_bytes(runtime, result);
+       kfree(bufs);
  end:
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
        down(&file->f_dentry->d_inode->i_sem);



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to