Skip to content

Commit

Permalink
powerpc/spufs: stop using access_ok
Browse files Browse the repository at this point in the history
Just use the proper non __-prefixed get/put_user variants where that is
not done yet.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Christoph Hellwig authored and Al Viro committed May 5, 2020
1 parent 88413a6 commit 6904d3d
Showing 1 changed file with 8 additions and 34 deletions.
42 changes: 8 additions & 34 deletions arch/powerpc/platforms/cell/spufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,17 +590,12 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
size_t len, loff_t *pos)
{
struct spu_context *ctx = file->private_data;
u32 mbox_data, __user *udata;
u32 mbox_data, __user *udata = (void __user *)buf;
ssize_t count;

if (len < 4)
return -EINVAL;

if (!access_ok(buf, len))
return -EFAULT;

udata = (void __user *)buf;

count = spu_acquire(ctx);
if (count)
return count;
Expand All @@ -616,7 +611,7 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
* but still need to return the data we have
* read successfully so far.
*/
ret = __put_user(mbox_data, udata);
ret = put_user(mbox_data, udata);
if (ret) {
if (!count)
count = -EFAULT;
Expand Down Expand Up @@ -698,17 +693,12 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
size_t len, loff_t *pos)
{
struct spu_context *ctx = file->private_data;
u32 ibox_data, __user *udata;
u32 ibox_data, __user *udata = (void __user *)buf;
ssize_t count;

if (len < 4)
return -EINVAL;

if (!access_ok(buf, len))
return -EFAULT;

udata = (void __user *)buf;

count = spu_acquire(ctx);
if (count)
goto out;
Expand All @@ -727,7 +717,7 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
}

/* if we can't write at all, return -EFAULT */
count = __put_user(ibox_data, udata);
count = put_user(ibox_data, udata);
if (count)
goto out_unlock;

Expand All @@ -741,7 +731,7 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
* but still need to return the data we have
* read successfully so far.
*/
ret = __put_user(ibox_data, udata);
ret = put_user(ibox_data, udata);
if (ret)
break;
}
Expand Down Expand Up @@ -836,17 +826,13 @@ static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
size_t len, loff_t *pos)
{
struct spu_context *ctx = file->private_data;
u32 wbox_data, __user *udata;
u32 wbox_data, __user *udata = (void __user *)buf;
ssize_t count;

if (len < 4)
return -EINVAL;

udata = (void __user *)buf;
if (!access_ok(buf, len))
return -EFAULT;

if (__get_user(wbox_data, udata))
if (get_user(wbox_data, udata))
return -EFAULT;

count = spu_acquire(ctx);
Expand All @@ -873,7 +859,7 @@ static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
/* write as much as possible */
for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
int ret;
ret = __get_user(wbox_data, udata);
ret = get_user(wbox_data, udata);
if (ret)
break;

Expand Down Expand Up @@ -1982,9 +1968,6 @@ static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
u32 stat, data;
int ret;

if (!access_ok(buf, len))
return -EFAULT;

ret = spu_acquire_saved(ctx);
if (ret)
return ret;
Expand Down Expand Up @@ -2028,9 +2011,6 @@ static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
u32 stat, data;
int ret;

if (!access_ok(buf, len))
return -EFAULT;

ret = spu_acquire_saved(ctx);
if (ret)
return ret;
Expand Down Expand Up @@ -2082,9 +2062,6 @@ static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
u32 data[ARRAY_SIZE(ctx->csa.spu_mailbox_data)];
int ret, count;

if (!access_ok(buf, len))
return -EFAULT;

ret = spu_acquire_saved(ctx);
if (ret)
return ret;
Expand Down Expand Up @@ -2143,9 +2120,6 @@ static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
struct spu_dma_info info;
int ret;

if (!access_ok(buf, len))
return -EFAULT;

ret = spu_acquire_saved(ctx);
if (ret)
return ret;
Expand Down

0 comments on commit 6904d3d

Please sign in to comment.