patch-2.4.27 linux-2.4.27/drivers/net/wireless/airo.c
Next file: linux-2.4.27/drivers/net/wireless/orinoco_pci.c
Previous file: linux-2.4.27/drivers/net/wan/farsync.h
Back to the patch index
Back to the overall index
- Lines: 72
- Date:
2004-08-07 16:26:05.233370569 -0700
- Orig file:
linux-2.4.26/drivers/net/wireless/airo.c
- Orig date:
2004-04-14 06:05:30.000000000 -0700
diff -urN linux-2.4.26/drivers/net/wireless/airo.c linux-2.4.27/drivers/net/wireless/airo.c
@@ -3666,19 +3666,22 @@
size_t len,
loff_t *offset )
{
- int i;
- int pos;
+ loff_t pos = *offset;
struct proc_data *priv = (struct proc_data*)file->private_data;
- if( !priv->rbuffer ) return -EINVAL;
+ if (!priv->rbuffer)
+ return -EINVAL;
- pos = *offset;
- for( i = 0; i+pos < priv->readlen && i < len; i++ ) {
- if (put_user( priv->rbuffer[i+pos], buffer+i ))
- return -EFAULT;
- }
- *offset += i;
- return i;
+ if (pos < 0)
+ return -EINVAL;
+ if (pos >= priv->readlen)
+ return 0;
+ if (len > priv->readlen - pos)
+ len = priv->readlen - pos;
+ if (copy_to_user(buffer, priv->rbuffer + pos, len))
+ return -EFAULT;
+ *offset = pos + len;
+ return len;
}
/*
@@ -3690,24 +3693,24 @@
size_t len,
loff_t *offset )
{
- int i;
- int pos;
+ loff_t pos = *offset;
struct proc_data *priv = (struct proc_data*)file->private_data;
- if ( !priv->wbuffer ) {
+ if (!priv->wbuffer)
return -EINVAL;
- }
-
- pos = *offset;
- for( i = 0; i + pos < priv->maxwritelen &&
- i < len; i++ ) {
- if (get_user( priv->wbuffer[i+pos], buffer + i ))
- return -EFAULT;
- }
- if ( i+pos > priv->writelen ) priv->writelen = i+file->f_pos;
- *offset += i;
- return i;
+ if (pos < 0)
+ return -EINVAL;
+ if (pos >= priv->maxwritelen)
+ return 0;
+ if (len > priv->maxwritelen - pos)
+ len = priv->maxwritelen - pos;
+ if (copy_from_user(priv->wbuffer + pos, buffer, len))
+ return -EFAULT;
+ if (pos + len > priv->writelen)
+ priv->writelen = pos + len;
+ *offset = pos + len;
+ return len;
}
static int proc_status_open( struct inode *inode, struct file *file ) {
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)