[PATCH] pcxx.c: get rid of verify_area and some cleanups

From: Arnaldo Carvalho de Melo (acme@conectiva.com.br)
Date: Thu Aug 24 2000 - 10:39:34 EST


Hi,

    Please take a look and consider applying.

                        - Arnaldo

--- linux-2.4.0-test7/drivers/char/pcxx.c Thu Aug 24 07:39:55 2000
+++ linux-2.4.0-test7.acme/drivers/char/pcxx.c Thu Aug 24 12:29:39 2000
@@ -39,6 +39,8 @@
  * and Xeve also.
  * 1.6.2 August, 7, 2000: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  * get rid of panics, release previously allocated resources
+ * 1.6.3 August, 23, 2000: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * cleaned up wrt verify_area
  *
  */
 
@@ -81,7 +83,7 @@
 #include <asm/bitops.h>
 #include <asm/semaphore.h>
 
-#define VERSION "1.6.2"
+#define VERSION "1.6.3"
 
 #include "digi.h"
 #include "fep.h"
@@ -713,11 +715,10 @@
                 tail &= (size - 1);
                 stlen = (head >= tail) ? (size - (head - tail) - 1) : (tail - head - 1);
                 count = MIN(stlen, count);
- if (count) {
- if (verify_area(VERIFY_READ, (char*)buf, count))
- count=0;
- else copy_from_user(ch->tmp_buf, buf, count);
- }
+ if (count)
+ if (copy_from_user(ch->tmp_buf, buf, count))
+ count = 0;
+
                 buf = ch->tmp_buf;
                 memoff(ch);
                 restore_flags(flags);
@@ -2124,7 +2125,6 @@
 static int pcxe_ioctl(struct tty_struct *tty, struct file * file,
                     unsigned int cmd, unsigned long arg)
 {
- int error;
         struct channel *ch = (struct channel *) tty->driver_data;
         volatile struct board_chan *bc;
         int retval;
@@ -2163,15 +2163,13 @@
                         return 0;
 
                 case TIOCGSOFTCAR:
- return put_user(C_CLOCAL(tty) ? 1 : 0,
- (unsigned int *) arg);
+ return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned int *)arg);
 
                 case TIOCSSOFTCAR:
                         {
                             unsigned int value;
- error = get_user( value, (unsigned int *) arg);
- if (error)
- return error;
+ if (get_user(value, (unsigned int *) arg))
+ return -EFAULT;
                             tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (value ? CLOCAL : 0));
                         }
                         return 0;
@@ -2199,18 +2197,16 @@
                         if(mstat & ch->dcd)
                                 mflag |= TIOCM_CD;
 
- error = put_user(mflag, (unsigned int *) arg);
- if(error)
- return error;
+ if (put_user(mflag, (unsigned int *) arg))
+ return -EFAULT;
                         break;
 
                 case TIOCMBIS:
                 case TIOCMBIC:
                 case TIOCMODS:
                 case TIOCMSET:
- error = get_user(mstat, (unsigned int *) arg);
- if(error)
- return error;
+ if (get_user(mstat, (unsigned int *) arg))
+ return -EFAULT;
 
                         mflag = 0;
                         if(mstat & TIOCM_DTR)
@@ -2262,10 +2258,8 @@
                         break;
 
                 case DIGI_GETA:
- if((error=verify_area(VERIFY_WRITE, (char*)arg, sizeof(digi_t))))
- return(error);
-
- copy_to_user((char*)arg, &ch->digiext, sizeof(digi_t));
+ if (copy_to_user((char*)arg, &ch->digiext, sizeof(digi_t)))
+ return -EFAULT;
                         break;
 
                 case DIGI_SETAW:
@@ -2282,10 +2276,8 @@
                         /* Fall Thru */
 
                 case DIGI_SETA:
- if((error=verify_area(VERIFY_READ, (char*)arg,sizeof(digi_t))))
- return(error);
-
- copy_from_user(&ch->digiext, (char*)arg, sizeof(digi_t));
+ if (copy_from_user(&ch->digiext, (char*)arg, sizeof(digi_t)))
+ return -EFAULT;
 #ifdef DEBUG_IOCTL
                         printk("ioctl(DIGI_SETA): flags = %x\n", ch->digiext.digi_flags);
 #endif
@@ -2319,10 +2311,8 @@
                         memoff(ch);
                         restore_flags(flags);
 
- if((error=verify_area(VERIFY_WRITE, (char*)arg,sizeof(dflow))))
- return(error);
-
- copy_to_user((char*)arg, &dflow, sizeof(dflow));
+ if (copy_to_user((char*)arg, &dflow, sizeof(dflow)))
+ return -EFAULT;
                         break;
 
                 case DIGI_SETAFLOW:
@@ -2335,10 +2325,8 @@
                                 stopc = ch->stopca;
                         }
 
- if((error=verify_area(VERIFY_READ, (char*)arg,sizeof(dflow))))
- return(error);
-
- copy_from_user(&dflow, (char*)arg, sizeof(dflow));
+ if (copy_from_user(&dflow, (char*)arg, sizeof(dflow)))
+ return -EFAULT;
 
                         if(dflow.startc != startc || dflow.stopc != stopc) {
                                 cli();
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:14 EST