Staging: intel_sst: return -EFAULT if copy_to_user()
Subsystems (2)
PATCH 1/2 Staging: intel_sst: return -EFAULT if copy_to_user()
copy_to_user() returns the number of bytes remaining to be copied but we want to return an error code. And that error code is -EFAULT not -EIO.
drivers/staging/intel_sst/intel_sst_app_interface.c +3 -1
@@ -865,6 +865,8 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) str_info->src =SST_DRV ; retval =copy_to_user (&str_param->stream_id, &retval,sizeof (__u32)); +if (retval) + retval = -EFAULT ; }else {if (retval = -SST_ERR_INVALID_PARAMS ) retval = -EINVAL ;
@@ -938,7 +940,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) retval =copy_to_user ((struct snd_sst_vol *)arg, &get_vol,sizeof (get_vol));if (retval) { - retval = -EIO ; + retval = -EFAULT ;break ; }/*sst_print_get_vol_info(str_id, &get_vol);*/
RE: [patch 1/2] Staging: intel_sst: return -EFAULT if
Quoted 30 lines
copy_to_user()returns the number of bytes remaining to be copied but we want to return an error code. And that error code is-EFAULTnot-EIO.Signed-off-by Dan Carpenter <[email protected]>drivers/staging/intel_sst/intel_sst_app_interface.c +2
-0@@ -865,6 +865,8 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) str_info->src = SST_DRV; retval =copy_to_user (&str_param->stream_id, &retval,sizeof (__u32)); +if (retval) + retval = -EFAULT ; }else {if (retval = -SST_ERR_INVALID_PARAMS )drivers/staging/intel_sst/intel_sst_app_interface.c +1
-1retval = -EINVAL ;@@ -938,7 +940,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) retval =copy_to_user ((struct snd_sst_vol *)arg, &get_vol,sizeof (get_vol));if (retval) { - retval = -EIO ; + retval = -EFAULT ;break ; }
Quoted 1 line
/*sst_print_get_vol_info(str_id, &get_vol);*/
Since retval is not used and value assigned is supposed to be -EFAULT, how about this?
if(copy_to_user()) return -EIO;
~Vinod
Re: [patch 1/2] Staging: intel_sst: return -EFAULT if
In reply to Dan CarpenterQuoted 12 lines · Vinod
Quoted 10 lines
drivers/staging/intel_sst/intel_sst_app_interface.c +1
-1@@ -938,7 +940,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) retval =copy_to_user ((struct snd_sst_vol *)arg, &get_vol,sizeof (get_vol));if (retval) { - retval = -EIO ; + retval = -EFAULT ;break ; }/*sst_print_get_vol_info(str_id, &get_vol);*/
Since retval is not used and value assigned is supposed to be
-EFAULT, how about this?
Quoted 3 lines
if(copy_to_user()) return -EIO;
No. No. retval is used. We can't return directly because we need to call unlock_kernel().
regards,
dan carpenter
RE: [patch 1/2] Staging: intel_sst: return -EFAULT if
In reply to Dan CarpenterQuoted 17 lines
Quoted 1 line
Review long intel_sst_ioctl(struct file *file_ptr, unsigned int
Quoted 1 line
(quoted diff) +0
-0@@ -938,7 +940,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned intcmd,
Quoted 11 lines
Quoted 9 lines
drivers/staging/intel_sst/intel_sst_app_interface.c +1
-1unsigned long arg) retval =copy_to_user ((struct snd_sst_vol *)arg, &get_vol,sizeof (get_vol));if (retval) { - retval = -EIO ; + retval = -EFAULT ;break ; }/*sst_print_get_vol_info(str_id, &get_vol);*/
Since retval is not used and value assigned is supposed to be
-EFAULT, how about this?Quoted 3 lines
if(copy_to_user()) return -EIO;
Quoted 2 lines
No. No. retval is used. We can't return directly because we need to call
unlock_kernel().
Kernel locking is already gone :) [1].
The point here was we don't need to store return value from this function Anyway you could have done it this way
if(copy_to_user()) {
retval = -EIO;
break;
}~Vinod
[1]: http://mailman.alsa-project.org/pipermail/alsa-devel/2010-October/032690.html
Re: [patch 1/2] Staging: intel_sst: return -EFAULT if
In reply to Dan CarpenterQuoted 5 lines · On Fri, 15 Oct 2010 05:44:07 +0200 Dan Carpenter <[email protected]> wrote:
copy_to_user()returns the number of bytes remaining to be copied but we want to return an error code. And that error code is-EFAULTnot-EIO.Signed-off-by Dan Carpenter <[email protected]>
Re: [patch 1/2] Staging: intel_sst: return -EFAULT if
In reply to Dan CarpenterQuoted 17 lines · On Fri, 15 Oct 2010 07:29:01 +0200 Dan Carpenter <[email protected]> wrote:
Quoted 12 lines · Vinod
Quoted 10 lines
drivers/staging/intel_sst/intel_sst_app_interface.c +1
-1@@ -938,7 +940,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) retval =copy_to_user ((struct snd_sst_vol *)arg, &get_vol,sizeof (get_vol));if (retval) { - retval = -EIO ; + retval = -EFAULT ;break ; }/*sst_print_get_vol_info(str_id, &get_vol);*/
Since retval is not used and value assigned is supposed to be
-EFAULT, how about this?Quoted 3 lines
if(copy_to_user()) return -EIO;
Quoted 2 lines
No. No. retval is used. We can't return directly because we need to call
unlock_kernel().
Dan - your tree is a couple of patches stale at this point if it has the lock_kernel in it - the lock_kernel has gone in the latest submission.
Re: [patch 1/2] Staging: intel_sst: return -EFAULT if
In reply to Dan CarpenterQuoted 20 lines · Alan Cox
Quoted 17 lines · On Fri, 15 Oct 2010 07:29:01 +0200 Dan Carpenter <[email protected]> wrote:
Quoted 15 lines · Vinod
Quoted 10 lines
drivers/staging/intel_sst/intel_sst_app_interface.c +1
-1@@ -938,7 +940,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg) retval =copy_to_user ((struct snd_sst_vol *)arg, &get_vol,sizeof (get_vol));if (retval) { - retval = -EIO ; + retval = -EFAULT ;break ; }/*sst_print_get_vol_info(str_id, &get_vol);*/
Since retval is not used and value assigned is supposed to be
-EFAULT, how about this?if(copy_to_user()) return -EIO;
Quoted 6 lines
Quoted 2 lines
No. No. retval is used. We can't return directly because we need to call
unlock_kernel().Dan - your tree is a couple of patches stale at this point if it has the
lock_kernelin it - thelock_kernelhas gone in the latest submission.
Yes. That went in last night. Vinod already told me.
I'll submit another patch which changes the file to the
if (copy_to_user()) retval = -EFAULT;
format. It will apply on top of the patches I sent already.
There are some other bugs I noticed when I wrote that so it's worth it to clean it up.
regards,
dan carpenter