diff options
Diffstat (limited to 'net/irda/irnet/irnet_ppp.c')
-rw-r--r-- | net/irda/irnet/irnet_ppp.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c index e0eab5927c4..f6e54fa97f4 100644 --- a/net/irda/irnet/irnet_ppp.c +++ b/net/irda/irnet/irnet_ppp.c | |||
@@ -628,8 +628,8 @@ dev_irnet_poll(struct file * file, | |||
628 | * This is the way pppd configure us and control us while the PPP | 628 | * This is the way pppd configure us and control us while the PPP |
629 | * instance is active. | 629 | * instance is active. |
630 | */ | 630 | */ |
631 | static int | 631 | static long |
632 | dev_irnet_ioctl(struct inode * inode, | 632 | dev_irnet_ioctl( |
633 | struct file * file, | 633 | struct file * file, |
634 | unsigned int cmd, | 634 | unsigned int cmd, |
635 | unsigned long arg) | 635 | unsigned long arg) |
@@ -660,6 +660,7 @@ dev_irnet_ioctl(struct inode * inode, | |||
660 | { | 660 | { |
661 | DEBUG(FS_INFO, "Entering PPP discipline.\n"); | 661 | DEBUG(FS_INFO, "Entering PPP discipline.\n"); |
662 | /* PPP channel setup (ap->chan in configued in dev_irnet_open())*/ | 662 | /* PPP channel setup (ap->chan in configued in dev_irnet_open())*/ |
663 | lock_kernel(); | ||
663 | err = ppp_register_channel(&ap->chan); | 664 | err = ppp_register_channel(&ap->chan); |
664 | if(err == 0) | 665 | if(err == 0) |
665 | { | 666 | { |
@@ -672,12 +673,14 @@ dev_irnet_ioctl(struct inode * inode, | |||
672 | } | 673 | } |
673 | else | 674 | else |
674 | DERROR(FS_ERROR, "Can't setup PPP channel...\n"); | 675 | DERROR(FS_ERROR, "Can't setup PPP channel...\n"); |
676 | unlock_kernel(); | ||
675 | } | 677 | } |
676 | else | 678 | else |
677 | { | 679 | { |
678 | /* In theory, should be N_TTY */ | 680 | /* In theory, should be N_TTY */ |
679 | DEBUG(FS_INFO, "Exiting PPP discipline.\n"); | 681 | DEBUG(FS_INFO, "Exiting PPP discipline.\n"); |
680 | /* Disconnect from the generic PPP layer */ | 682 | /* Disconnect from the generic PPP layer */ |
683 | lock_kernel(); | ||
681 | if(ap->ppp_open) | 684 | if(ap->ppp_open) |
682 | { | 685 | { |
683 | ap->ppp_open = 0; | 686 | ap->ppp_open = 0; |
@@ -686,24 +689,20 @@ dev_irnet_ioctl(struct inode * inode, | |||
686 | else | 689 | else |
687 | DERROR(FS_ERROR, "Channel not registered !\n"); | 690 | DERROR(FS_ERROR, "Channel not registered !\n"); |
688 | err = 0; | 691 | err = 0; |
692 | unlock_kernel(); | ||
689 | } | 693 | } |
690 | break; | 694 | break; |
691 | 695 | ||
692 | /* Query PPP channel and unit number */ | 696 | /* Query PPP channel and unit number */ |
693 | case PPPIOCGCHAN: | 697 | case PPPIOCGCHAN: |
694 | if(!ap->ppp_open) | 698 | if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan), |
695 | break; | 699 | (int __user *)argp)) |
696 | if(put_user(ppp_channel_index(&ap->chan), (int __user *)argp)) | 700 | err = 0; |
697 | break; | ||
698 | DEBUG(FS_INFO, "Query channel.\n"); | ||
699 | err = 0; | ||
700 | break; | 701 | break; |
701 | case PPPIOCGUNIT: | 702 | case PPPIOCGUNIT: |
702 | if(!ap->ppp_open) | 703 | lock_kernel(); |
703 | break; | 704 | if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan), |
704 | if(put_user(ppp_unit_number(&ap->chan), (int __user *)argp)) | 705 | (int __user *)argp)) |
705 | break; | ||
706 | DEBUG(FS_INFO, "Query unit number.\n"); | ||
707 | err = 0; | 706 | err = 0; |
708 | break; | 707 | break; |
709 | 708 | ||
@@ -723,34 +722,39 @@ dev_irnet_ioctl(struct inode * inode, | |||
723 | DEBUG(FS_INFO, "Standard PPP ioctl.\n"); | 722 | DEBUG(FS_INFO, "Standard PPP ioctl.\n"); |
724 | if(!capable(CAP_NET_ADMIN)) | 723 | if(!capable(CAP_NET_ADMIN)) |
725 | err = -EPERM; | 724 | err = -EPERM; |
726 | else | 725 | else { |
726 | lock_kernel(); | ||
727 | err = ppp_irnet_ioctl(&ap->chan, cmd, arg); | 727 | err = ppp_irnet_ioctl(&ap->chan, cmd, arg); |
728 | unlock_kernel(); | ||
729 | } | ||
728 | break; | 730 | break; |
729 | 731 | ||
730 | /* TTY IOCTLs : Pretend that we are a tty, to keep pppd happy */ | 732 | /* TTY IOCTLs : Pretend that we are a tty, to keep pppd happy */ |
731 | /* Get termios */ | 733 | /* Get termios */ |
732 | case TCGETS: | 734 | case TCGETS: |
733 | DEBUG(FS_INFO, "Get termios.\n"); | 735 | DEBUG(FS_INFO, "Get termios.\n"); |
736 | lock_kernel(); | ||
734 | #ifndef TCGETS2 | 737 | #ifndef TCGETS2 |
735 | if(kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios)) | 738 | if(!kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios)) |
736 | break; | 739 | err = 0; |
737 | #else | 740 | #else |
738 | if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios)) | 741 | if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios)) |
739 | break; | 742 | err = 0; |
740 | #endif | 743 | #endif |
741 | err = 0; | 744 | unlock_kernel(); |
742 | break; | 745 | break; |
743 | /* Set termios */ | 746 | /* Set termios */ |
744 | case TCSETSF: | 747 | case TCSETSF: |
745 | DEBUG(FS_INFO, "Set termios.\n"); | 748 | DEBUG(FS_INFO, "Set termios.\n"); |
749 | lock_kernel(); | ||
746 | #ifndef TCGETS2 | 750 | #ifndef TCGETS2 |
747 | if(user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp)) | 751 | if(!user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp)) |
748 | break; | 752 | err = 0; |
749 | #else | 753 | #else |
750 | if(user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp)) | 754 | if(!user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp)) |
751 | break; | 755 | err = 0; |
752 | #endif | 756 | #endif |
753 | err = 0; | 757 | unlock_kernel(); |
754 | break; | 758 | break; |
755 | 759 | ||
756 | /* Set DTR/RTS */ | 760 | /* Set DTR/RTS */ |
@@ -773,7 +777,9 @@ dev_irnet_ioctl(struct inode * inode, | |||
773 | * We should also worry that we don't accept junk here and that | 777 | * We should also worry that we don't accept junk here and that |
774 | * we get rid of our own buffers */ | 778 | * we get rid of our own buffers */ |
775 | #ifdef FLUSH_TO_PPP | 779 | #ifdef FLUSH_TO_PPP |
780 | lock_kernel(); | ||
776 | ppp_output_wakeup(&ap->chan); | 781 | ppp_output_wakeup(&ap->chan); |
782 | unlock_kernel(); | ||
777 | #endif /* FLUSH_TO_PPP */ | 783 | #endif /* FLUSH_TO_PPP */ |
778 | err = 0; | 784 | err = 0; |
779 | break; | 785 | break; |
@@ -788,7 +794,7 @@ dev_irnet_ioctl(struct inode * inode, | |||
788 | 794 | ||
789 | default: | 795 | default: |
790 | DERROR(FS_ERROR, "Unsupported ioctl (0x%X)\n", cmd); | 796 | DERROR(FS_ERROR, "Unsupported ioctl (0x%X)\n", cmd); |
791 | err = -ENOIOCTLCMD; | 797 | err = -ENOTTY; |
792 | } | 798 | } |
793 | 799 | ||
794 | DEXIT(FS_TRACE, " - err = 0x%X\n", err); | 800 | DEXIT(FS_TRACE, " - err = 0x%X\n", err); |