lkml.org 
[lkml]   [2000]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] drivers/char/riscom8.c: get rid of verify_area and other cleanups
Hi,

Please take a look and consider applying.

- Arnaldo

--- linux-2.4.0-test7/drivers/char/riscom8.c Thu Oct 28 15:42:02 1999
+++ linux-2.4.0-test7.acme/drivers/char/riscom8.c Fri Aug 25 08:42:18 2000
@@ -25,6 +25,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Revision 1.0
+ *
+ * Changes:
+ * Arnaldo Carvalho de Melo <acme@conectiva.com.br> 2000/08/25
+ * - get rid of verify_area, check copy_*_user return, small cleanups
*/

#include <linux/module.h>
@@ -1228,7 +1232,11 @@
break;

if (from_user) {
- copy_from_user(tmp_buf, buf, c);
+ if (copy_from_user(tmp_buf, buf, c)) {
+ restore_flags(flags);
+ up(&tmp_buf_sem);
+ return 0;
+ }
c = MIN(c, MIN(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
SERIAL_XMIT_SIZE - port->xmit_head));
memcpy(port->xmit_buf + port->xmit_head, tmp_buf, c);
@@ -1356,8 +1364,7 @@
| ((status & MSVR_CD) ? TIOCM_CAR : 0)
| ((status & MSVR_DSR) ? TIOCM_DSR : 0)
| ((status & MSVR_CTS) ? TIOCM_CTS : 0);
- put_user(result, value);
- return 0;
+ return put_user(result, value);
}

static int rc_set_modem_info(struct riscom_port * port, unsigned int cmd,
@@ -1426,13 +1433,8 @@
struct riscom_board *bp = port_Board(port);
int change_speed;
unsigned long flags;
- int error;
-
- error = verify_area(VERIFY_READ, (void *) newinfo, sizeof(tmp));
- if (error)
- return error;
- copy_from_user(&tmp, newinfo, sizeof(tmp));

+ copy_from_user_ret(&tmp, newinfo, sizeof(tmp), -EFAULT);
#if 0
if ((tmp.irq != bp->irq) ||
(tmp.port != bp->base) ||
@@ -1474,11 +1476,6 @@
{
struct serial_struct tmp;
struct riscom_board *bp = port_Board(port);
- int error;
-
- error = verify_area(VERIFY_WRITE, (void *) retinfo, sizeof(tmp));
- if (error)
- return error;

memset(&tmp, 0, sizeof(tmp));
tmp.type = PORT_CIRRUS;
@@ -1490,7 +1487,7 @@
tmp.close_delay = port->close_delay * HZ/100;
tmp.closing_wait = port->closing_wait * HZ/100;
tmp.xmit_fifo_size = CD180_NFIFO;
- copy_to_user(retinfo, &tmp, sizeof(tmp));
+ copy_to_user_ret(retinfo, &tmp, sizeof(tmp), -EFAULT);
return 0;
}

@@ -1524,18 +1521,13 @@
case TIOCGSOFTCAR:
return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned int *) arg);
case TIOCSSOFTCAR:
- retval = get_user(arg,(unsigned int *) arg);
- if (retval)
- return retval;
+ if (get_user(arg,(unsigned int *) arg))
+ return -EFAULT;
tty->termios->c_cflag =
((tty->termios->c_cflag & ~CLOCAL) |
(arg ? CLOCAL : 0));
return 0;
case TIOCMGET:
- error = verify_area(VERIFY_WRITE, (void *) arg,
- sizeof(unsigned int));
- if (error)
- return error;
return rc_get_modem_info(port, (unsigned int *) arg);
case TIOCMBIS:
case TIOCMBIC:
-
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/
\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.023 / U:1.368 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site