aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2006-10-24 12:01:42 -0400
committerPaul Mackerras <paulus@samba.org>2006-10-24 22:10:41 -0400
commit274cef5e9d0e494ad84dbc28513b0bb6e3d847ae (patch)
tree9d10487ca02ed71a9f95412d5ae949a44c15a37a /arch/powerpc
parentf6b301b89b7bf0bb872da4f37dc28240413cbae7 (diff)
[POWERPC] spufs: fix another off-by-one bug in spufs_mbox_read
Currently, spufs_mbox_read transfers more bytes than requested on a read. If you ask for four bytes, you get eight. This fixes it to transfer the largest multiple of four bytes that is less than or equal to the number you asked for. Note: one nasty property of this file in spufs is that you can only read multiples of four bytes in the first place, since there is no way to atomically put back a few bytes into the hardware register. Thus, reading less than four bytes returns -EINVAL. Asking for more than four returns the largest possible multiple of four. Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 0de8e114e6b..533e2723e18 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -385,7 +385,7 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
385 udata = (void __user *)buf; 385 udata = (void __user *)buf;
386 386
387 spu_acquire(ctx); 387 spu_acquire(ctx);
388 for (count = 0; count <= len; count += 4, udata++) { 388 for (count = 0; (count + 4) <= len; count += 4, udata++) {
389 int ret; 389 int ret;
390 ret = ctx->ops->mbox_read(ctx, &mbox_data); 390 ret = ctx->ops->mbox_read(ctx, &mbox_data);
391 if (ret == 0) 391 if (ret == 0)