--- 20050223/xen-unstable/linux-2.6.10-xen-sparse/arch/xen/kernel/devmem.c 2005-02-23 05:12:38.000000000 +0100 +++ mandrake/SOURCES/linux-2.6.10.3mdk-xen/arch/xen/kernel/devmem.c 2005-02-24 12:23:15.920125424 +0100 @@ -43,7 +43,7 @@ static ssize_t read_mem(struct file * fi size_t count, loff_t *ppos) { unsigned long i, p = *ppos; - ssize_t read = 0; + ssize_t read = -EFAULT; void *v; if ((v = ioremap(p, count)) == NULL) { @@ -56,16 +56,21 @@ static ssize_t read_mem(struct file * fi */ for (i = 0; i < count; i++) if (put_user(0, buf+i)) - return -EFAULT; + goto leave; return count; } if (copy_to_user(buf, v, count)) - return -EFAULT; - iounmap(v); + goto cleanup; - read += count; + read = count; *ppos += read; + cleanup: + + iounmap(v); + + leave: + return read; } @@ -73,18 +78,24 @@ static ssize_t write_mem(struct file * f size_t count, loff_t *ppos) { unsigned long p = *ppos; - ssize_t written = 0; + ssize_t written = -EFAULT; void *v; if ((v = ioremap(p, count)) == NULL) - return -EFAULT; + goto leave; + if (copy_to_user(v, buf, count)) - return -EFAULT; - iounmap(v); + goto cleanup; - written += count; + written = count; *ppos += written; + cleanup: + + iounmap(v); + + leave: + return written; }