patch-2.4.27 linux-2.4.27/drivers/sbus/char/flash.c

Next file: linux-2.4.27/drivers/scsi/ChangeLog.ips
Previous file: linux-2.4.27/drivers/s390/s390io.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.26/drivers/sbus/char/flash.c linux-2.4.27/drivers/sbus/char/flash.c
@@ -105,9 +105,15 @@
 flash_read(struct file * file, char * buf,
 	   size_t count, loff_t *ppos)
 {
-	unsigned long p = file->f_pos;
+	loff_t p = *ppos;
 	int i;
 	
+	if (p > flash.read_size)
+		return 0;
+
+	if (p < 0)
+		return -EINVAL;
+
 	if (count > flash.read_size - p)
 		count = flash.read_size - p;
 
@@ -118,7 +124,7 @@
 		buf++;
 	}
 
-	file->f_pos += count;
+	*ppos = p + count;
 	return count;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)