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

Modified Files:
        control.c memory.c 
Log Message:
Reduced stack usage using kmalloc()

Index: control.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/core/control.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- control.c   29 Sep 2002 15:49:04 -0000      1.15
+++ control.c   14 Oct 2002 16:33:27 -0000      1.16
@@ -426,25 +426,28 @@
 
 static int snd_ctl_elem_read(snd_card_t *card, snd_ctl_elem_value_t *_control)
 {
-       snd_ctl_elem_value_t control;
+       snd_ctl_elem_value_t *control;
        snd_kcontrol_t *kctl;
        int result, indirect;
        
-       if (copy_from_user(&control, _control, sizeof(control)))
+       control = kmalloc(sizeof(*control), GFP_KERNEL);
+       if (control == NULL)
+               return -ENOMEM; 
+       if (copy_from_user(control, _control, sizeof(*control)))
                return -EFAULT;
        read_lock(&card->control_rwlock);
-       kctl = snd_ctl_find_id(card, &control.id);
+       kctl = snd_ctl_find_id(card, &control->id);
        if (kctl == NULL) {
                result = -ENOENT;
        } else {
                indirect = kctl->access & SNDRV_CTL_ELEM_ACCESS_INDIRECT ? 1 : 0;
-               if (control.indirect != indirect) {
+               if (control->indirect != indirect) {
                        result = -EACCES;
                } else {
                        if ((kctl->access & SNDRV_CTL_ELEM_ACCESS_READ) && kctl->get 
!= NULL) {
-                               result = kctl->get(kctl, &control);
+                               result = kctl->get(kctl, control);
                                if (result >= 0)
-                                       control.id = kctl->id;
+                                       control->id = kctl->id;
                        } else
                                result = -EPERM;
                }
@@ -453,25 +456,29 @@
        if (result >= 0)
                if (copy_to_user(_control, &control, sizeof(control)))
                        return -EFAULT;
+       kfree(control);
        return result;
 }
 
 static int snd_ctl_elem_write(snd_ctl_file_t *file, snd_ctl_elem_value_t *_control)
 {
        snd_card_t *card = file->card;
-       snd_ctl_elem_value_t control;
+       snd_ctl_elem_value_t *control;
        snd_kcontrol_t *kctl;
        int result, indirect;
-       
-       if (copy_from_user(&control, _control, sizeof(control)))
+
+       control = kmalloc(sizeof(*control), GFP_KERNEL);
+       if (control == NULL)
+               return -ENOMEM; 
+       if (copy_from_user(control, _control, sizeof(*control)))
                return -EFAULT;
        read_lock(&card->control_rwlock);
-       kctl = snd_ctl_find_id(card, &control.id);
+       kctl = snd_ctl_find_id(card, &control->id);
        if (kctl == NULL) {
                result = -ENOENT;
        } else {
                indirect = kctl->access & SNDRV_CTL_ELEM_ACCESS_INDIRECT ? 1 : 0;
-               if (control.indirect != indirect) {
+               if (control->indirect != indirect) {
                        result = -EACCES;
                } else {
                        read_lock(&card->control_owner_lock);
@@ -480,9 +487,9 @@
                            (kctl->owner != NULL && kctl->owner != file)) {
                                result = -EPERM;
                        } else {
-                               result = kctl->put(kctl, &control);
+                               result = kctl->put(kctl, control);
                                if (result >= 0)
-                                       control.id = kctl->id;
+                                       control->id = kctl->id;
                        }
                        read_unlock(&card->control_owner_lock);
                        if (result > 0) {
@@ -498,6 +505,7 @@
        if (result >= 0)
                if (copy_to_user(_control, &control, sizeof(control)))
                        return -EFAULT;
+       kfree(control);
        return result;
 }
 

Index: memory.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/core/memory.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- memory.c    12 Sep 2002 09:02:11 -0000      1.21
+++ memory.c    14 Oct 2002 16:33:27 -0000      1.22
@@ -499,10 +499,10 @@
 
 int copy_to_user_fromio(void *dst, unsigned long src, size_t count)
 {
-#if defined(__i386_) || defined(CONFIG_SPARC32)
+#if defined(__i386__) || defined(CONFIG_SPARC32)
        return copy_to_user(dst, (const void*)src, count) ? -EFAULT : 0;
 #else
-       char buf[1024];
+       char buf[256];
        while (count) {
                size_t c = count;
                if (c > sizeof(buf))
@@ -520,10 +520,10 @@
 
 int copy_from_user_toio(unsigned long dst, const void *src, size_t count)
 {
-#if defined(__i386_) || defined(CONFIG_SPARC32)
+#if defined(__i386__) || defined(CONFIG_SPARC32)
        return copy_from_user((void*)dst, src, count) ? -EFAULT : 0;
 #else
-       char buf[1024];
+       char buf[256];
        while (count) {
                size_t c = count;
                if (c > sizeof(buf))



-------------------------------------------------------
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