]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/char/ip2/ip2main.c
ip2: return -EFAULT on copy_to_user errors
[net-next-2.6.git] / drivers / char / ip2 / ip2main.c
index 911e1da6def225af3163809bd2eeaec394931ab4..d4b71e8d0d23a13648be2e55f60f606f55b99edd 100644 (file)
@@ -1486,7 +1486,9 @@ ip2_open( PTTY tty, struct file *pFile )
 
        if ( tty_hung_up_p(pFile) || ( pCh->flags & ASYNC_CLOSING )) {
                if ( pCh->flags & ASYNC_CLOSING ) {
+                       tty_unlock();
                        schedule();
+                       tty_lock();
                }
                if ( tty_hung_up_p(pFile) ) {
                        set_current_state( TASK_RUNNING );
@@ -1548,7 +1550,9 @@ ip2_open( PTTY tty, struct file *pFile )
                        rc = (( pCh->flags & ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS);
                        break;
                }
+               tty_unlock();
                schedule();
+               tty_lock();
        }
        set_current_state( TASK_RUNNING );
        remove_wait_queue(&pCh->open_wait, &wait);
@@ -1646,7 +1650,7 @@ ip2_close( PTTY tty, struct file *pFile )
        /* disable DSS reporting */
        i2QueueCommands(PTYPE_INLINE, pCh, 100, 4,
                                CMD_DCD_NREP, CMD_CTS_NREP, CMD_DSR_NREP, CMD_RI_NREP);
-       if ( !tty || (tty->termios->c_cflag & HUPCL) ) {
+       if (tty->termios->c_cflag & HUPCL) {
                i2QueueCommands(PTYPE_INLINE, pCh, 100, 2, CMD_RTSDN, CMD_DTRDN);
                pCh->dataSetOut &= ~(I2_DTR | I2_RTS);
                i2QueueCommands( PTYPE_INLINE, pCh, 100, 1, CMD_PAUSE(25));
@@ -2926,6 +2930,8 @@ ip2_ipl_ioctl (struct file *pFile, UINT cmd, ULONG arg )
                                if ( pCh )
                                {
                                        rc = copy_to_user(argp, pCh, sizeof(i2ChanStr));
+                                       if (rc)
+                                               rc = -EFAULT;
                                } else {
                                        rc = -ENODEV;
                                }