aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/mISDN/l1oip_core.c
diff options
context:
space:
mode:
authorFrank Seidel <frank@f-seidel.de>2009-05-22 07:04:51 -0400
committerDavid S. Miller <davem@davemloft.net>2009-05-25 03:55:28 -0400
commit3dc403939c73ac372f2c95b5099dfdf396fe4ecc (patch)
tree471091981fd0626da8688bae677045598fcbc453 /drivers/isdn/mISDN/l1oip_core.c
parent5b277b8605f4c8fbd13302df33ab4570f844c1ff (diff)
mISDN: Add allocation of recvbuf[1500] at run time to reduce stack size
Before: 1656 bytes on i386, now 164. Modified by Andreas Eversberg <andreas@eversberg.eu> Signed-off-by: Frank Seidel <frank@f-seidel.de> Signed-off-by: Andreas Eversberg <andreas@eversberg.eu> Signed-off-by: Karsten Keil <keil@b1-systems.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/mISDN/l1oip_core.c')
-rw-r--r--drivers/isdn/mISDN/l1oip_core.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index abe574989572..ea3c3aa2004b 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -663,18 +663,28 @@ l1oip_socket_thread(void *data)
663 struct iovec iov; 663 struct iovec iov;
664 mm_segment_t oldfs; 664 mm_segment_t oldfs;
665 struct sockaddr_in sin_rx; 665 struct sockaddr_in sin_rx;
666 unsigned char recvbuf[1500]; 666 unsigned char *recvbuf;
667 size_t recvbuf_size = 1500;
667 int recvlen; 668 int recvlen;
668 struct socket *socket = NULL; 669 struct socket *socket = NULL;
669 DECLARE_COMPLETION(wait); 670 DECLARE_COMPLETION(wait);
670 671
672 /* allocate buffer memory */
673 recvbuf = kmalloc(recvbuf_size, GFP_KERNEL);
674 if (!recvbuf) {
675 printk(KERN_ERR "%s: Failed to alloc recvbuf.\n", __func__);
676 ret = -ENOMEM;
677 goto fail;
678 }
679
671 /* make daemon */ 680 /* make daemon */
672 allow_signal(SIGTERM); 681 allow_signal(SIGTERM);
673 682
674 /* create socket */ 683 /* create socket */
675 if (sock_create(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &socket)) { 684 if (sock_create(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &socket)) {
676 printk(KERN_ERR "%s: Failed to create socket.\n", __func__); 685 printk(KERN_ERR "%s: Failed to create socket.\n", __func__);
677 return -EIO; 686 ret = -EIO;
687 goto fail;
678 } 688 }
679 689
680 /* set incoming address */ 690 /* set incoming address */
@@ -730,10 +740,10 @@ l1oip_socket_thread(void *data)
730 __func__); 740 __func__);
731 while (!signal_pending(current)) { 741 while (!signal_pending(current)) {
732 iov.iov_base = recvbuf; 742 iov.iov_base = recvbuf;
733 iov.iov_len = sizeof(recvbuf); 743 iov.iov_len = recvbuf_size;
734 oldfs = get_fs(); 744 oldfs = get_fs();
735 set_fs(KERNEL_DS); 745 set_fs(KERNEL_DS);
736 recvlen = sock_recvmsg(socket, &msg, sizeof(recvbuf), 0); 746 recvlen = sock_recvmsg(socket, &msg, recvbuf_size, 0);
737 set_fs(oldfs); 747 set_fs(oldfs);
738 if (recvlen > 0) { 748 if (recvlen > 0) {
739 l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen); 749 l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen);
@@ -760,6 +770,9 @@ l1oip_socket_thread(void *data)
760 __func__); 770 __func__);
761 771
762fail: 772fail:
773 /* free recvbuf */
774 kfree(recvbuf);
775
763 /* close socket */ 776 /* close socket */
764 if (socket) 777 if (socket)
765 sock_release(socket); 778 sock_release(socket);