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