aboutsummaryrefslogtreecommitdiffstats
path: root/net/irda/irnet/irnet_ppp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/irda/irnet/irnet_ppp.c')
-rw-r--r--net/irda/irnet/irnet_ppp.c69
1 files changed, 46 insertions, 23 deletions
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c
index dfe7b38dd4af..0993bd454ea5 100644
--- a/net/irda/irnet/irnet_ppp.c
+++ b/net/irda/irnet/irnet_ppp.c
@@ -166,7 +166,7 @@ irnet_ctrl_write(irnet_socket * ap,
166 } 166 }
167 167
168 /* Success : we have parsed all commands successfully */ 168 /* Success : we have parsed all commands successfully */
169 return(count); 169 return count;
170} 170}
171 171
172#ifdef INITIAL_DISCOVERY 172#ifdef INITIAL_DISCOVERY
@@ -300,7 +300,7 @@ irnet_ctrl_read(irnet_socket * ap,
300 } 300 }
301 301
302 DEXIT(CTRL_TRACE, "\n"); 302 DEXIT(CTRL_TRACE, "\n");
303 return(strlen(event)); 303 return strlen(event);
304 } 304 }
305#endif /* INITIAL_DISCOVERY */ 305#endif /* INITIAL_DISCOVERY */
306 306
@@ -409,7 +409,7 @@ irnet_ctrl_read(irnet_socket * ap,
409 } 409 }
410 410
411 DEXIT(CTRL_TRACE, "\n"); 411 DEXIT(CTRL_TRACE, "\n");
412 return(strlen(event)); 412 return strlen(event);
413} 413}
414 414
415/*------------------------------------------------------------------*/ 415/*------------------------------------------------------------------*/
@@ -480,7 +480,6 @@ dev_irnet_open(struct inode * inode,
480 ap = kzalloc(sizeof(*ap), GFP_KERNEL); 480 ap = kzalloc(sizeof(*ap), GFP_KERNEL);
481 DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n"); 481 DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n");
482 482
483 lock_kernel();
484 /* initialize the irnet structure */ 483 /* initialize the irnet structure */
485 ap->file = file; 484 ap->file = file;
486 485
@@ -502,18 +501,20 @@ dev_irnet_open(struct inode * inode,
502 { 501 {
503 DERROR(FS_ERROR, "Can't setup IrDA link...\n"); 502 DERROR(FS_ERROR, "Can't setup IrDA link...\n");
504 kfree(ap); 503 kfree(ap);
505 unlock_kernel(); 504
506 return err; 505 return err;
507 } 506 }
508 507
509 /* For the control channel */ 508 /* For the control channel */
510 ap->event_index = irnet_events.index; /* Cancel all past events */ 509 ap->event_index = irnet_events.index; /* Cancel all past events */
511 510
511 mutex_init(&ap->lock);
512
512 /* Put our stuff where we will be able to find it later */ 513 /* Put our stuff where we will be able to find it later */
513 file->private_data = ap; 514 file->private_data = ap;
514 515
515 DEXIT(FS_TRACE, " - ap=0x%p\n", ap); 516 DEXIT(FS_TRACE, " - ap=0x%p\n", ap);
516 unlock_kernel(); 517
517 return 0; 518 return 0;
518} 519}
519 520
@@ -623,7 +624,7 @@ dev_irnet_poll(struct file * file,
623 mask |= irnet_ctrl_poll(ap, file, wait); 624 mask |= irnet_ctrl_poll(ap, file, wait);
624 625
625 DEXIT(FS_TRACE, " - mask=0x%X\n", mask); 626 DEXIT(FS_TRACE, " - mask=0x%X\n", mask);
626 return(mask); 627 return mask;
627} 628}
628 629
629/*------------------------------------------------------------------*/ 630/*------------------------------------------------------------------*/
@@ -664,7 +665,9 @@ dev_irnet_ioctl(
664 { 665 {
665 DEBUG(FS_INFO, "Entering PPP discipline.\n"); 666 DEBUG(FS_INFO, "Entering PPP discipline.\n");
666 /* PPP channel setup (ap->chan in configued in dev_irnet_open())*/ 667 /* PPP channel setup (ap->chan in configued in dev_irnet_open())*/
667 lock_kernel(); 668 if (mutex_lock_interruptible(&ap->lock))
669 return -EINTR;
670
668 err = ppp_register_channel(&ap->chan); 671 err = ppp_register_channel(&ap->chan);
669 if(err == 0) 672 if(err == 0)
670 { 673 {
@@ -677,14 +680,17 @@ dev_irnet_ioctl(
677 } 680 }
678 else 681 else
679 DERROR(FS_ERROR, "Can't setup PPP channel...\n"); 682 DERROR(FS_ERROR, "Can't setup PPP channel...\n");
680 unlock_kernel(); 683
684 mutex_unlock(&ap->lock);
681 } 685 }
682 else 686 else
683 { 687 {
684 /* In theory, should be N_TTY */ 688 /* In theory, should be N_TTY */
685 DEBUG(FS_INFO, "Exiting PPP discipline.\n"); 689 DEBUG(FS_INFO, "Exiting PPP discipline.\n");
686 /* Disconnect from the generic PPP layer */ 690 /* Disconnect from the generic PPP layer */
687 lock_kernel(); 691 if (mutex_lock_interruptible(&ap->lock))
692 return -EINTR;
693
688 if(ap->ppp_open) 694 if(ap->ppp_open)
689 { 695 {
690 ap->ppp_open = 0; 696 ap->ppp_open = 0;
@@ -693,24 +699,31 @@ dev_irnet_ioctl(
693 else 699 else
694 DERROR(FS_ERROR, "Channel not registered !\n"); 700 DERROR(FS_ERROR, "Channel not registered !\n");
695 err = 0; 701 err = 0;
696 unlock_kernel(); 702
703 mutex_unlock(&ap->lock);
697 } 704 }
698 break; 705 break;
699 706
700 /* Query PPP channel and unit number */ 707 /* Query PPP channel and unit number */
701 case PPPIOCGCHAN: 708 case PPPIOCGCHAN:
702 lock_kernel(); 709 if (mutex_lock_interruptible(&ap->lock))
710 return -EINTR;
711
703 if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan), 712 if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan),
704 (int __user *)argp)) 713 (int __user *)argp))
705 err = 0; 714 err = 0;
706 unlock_kernel(); 715
716 mutex_unlock(&ap->lock);
707 break; 717 break;
708 case PPPIOCGUNIT: 718 case PPPIOCGUNIT:
709 lock_kernel(); 719 if (mutex_lock_interruptible(&ap->lock))
720 return -EINTR;
721
710 if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan), 722 if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan),
711 (int __user *)argp)) 723 (int __user *)argp))
712 err = 0; 724 err = 0;
713 unlock_kernel(); 725
726 mutex_unlock(&ap->lock);
714 break; 727 break;
715 728
716 /* All these ioctls can be passed both directly and from ppp_generic, 729 /* All these ioctls can be passed both directly and from ppp_generic,
@@ -730,9 +743,12 @@ dev_irnet_ioctl(
730 if(!capable(CAP_NET_ADMIN)) 743 if(!capable(CAP_NET_ADMIN))
731 err = -EPERM; 744 err = -EPERM;
732 else { 745 else {
733 lock_kernel(); 746 if (mutex_lock_interruptible(&ap->lock))
747 return -EINTR;
748
734 err = ppp_irnet_ioctl(&ap->chan, cmd, arg); 749 err = ppp_irnet_ioctl(&ap->chan, cmd, arg);
735 unlock_kernel(); 750
751 mutex_unlock(&ap->lock);
736 } 752 }
737 break; 753 break;
738 754
@@ -740,7 +756,9 @@ dev_irnet_ioctl(
740 /* Get termios */ 756 /* Get termios */
741 case TCGETS: 757 case TCGETS:
742 DEBUG(FS_INFO, "Get termios.\n"); 758 DEBUG(FS_INFO, "Get termios.\n");
743 lock_kernel(); 759 if (mutex_lock_interruptible(&ap->lock))
760 return -EINTR;
761
744#ifndef TCGETS2 762#ifndef TCGETS2
745 if(!kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios)) 763 if(!kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios))
746 err = 0; 764 err = 0;
@@ -748,12 +766,15 @@ dev_irnet_ioctl(
748 if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios)) 766 if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios))
749 err = 0; 767 err = 0;
750#endif 768#endif
751 unlock_kernel(); 769
770 mutex_unlock(&ap->lock);
752 break; 771 break;
753 /* Set termios */ 772 /* Set termios */
754 case TCSETSF: 773 case TCSETSF:
755 DEBUG(FS_INFO, "Set termios.\n"); 774 DEBUG(FS_INFO, "Set termios.\n");
756 lock_kernel(); 775 if (mutex_lock_interruptible(&ap->lock))
776 return -EINTR;
777
757#ifndef TCGETS2 778#ifndef TCGETS2
758 if(!user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp)) 779 if(!user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp))
759 err = 0; 780 err = 0;
@@ -761,7 +782,8 @@ dev_irnet_ioctl(
761 if(!user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp)) 782 if(!user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp))
762 err = 0; 783 err = 0;
763#endif 784#endif
764 unlock_kernel(); 785
786 mutex_unlock(&ap->lock);
765 break; 787 break;
766 788
767 /* Set DTR/RTS */ 789 /* Set DTR/RTS */
@@ -784,9 +806,10 @@ dev_irnet_ioctl(
784 * We should also worry that we don't accept junk here and that 806 * We should also worry that we don't accept junk here and that
785 * we get rid of our own buffers */ 807 * we get rid of our own buffers */
786#ifdef FLUSH_TO_PPP 808#ifdef FLUSH_TO_PPP
787 lock_kernel(); 809 if (mutex_lock_interruptible(&ap->lock))
810 return -EINTR;
788 ppp_output_wakeup(&ap->chan); 811 ppp_output_wakeup(&ap->chan);
789 unlock_kernel(); 812 mutex_unlock(&ap->lock);
790#endif /* FLUSH_TO_PPP */ 813#endif /* FLUSH_TO_PPP */
791 err = 0; 814 err = 0;
792 break; 815 break;