lkml.org 
[lkml]   [2018]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] staging: pi433: fix race condition in pi433_ioctl
On Tue, Jun 12, 2018 at 09:47:41PM -0400, Hugo Lefeuvre wrote:
> drivers/staging/pi433/pi433_if.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
> index b061f77dda41..3ec1ed01d04b 100644
> --- a/drivers/staging/pi433/pi433_if.c
> +++ b/drivers/staging/pi433/pi433_if.c
> @@ -880,6 +880,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> int retval = 0;
> struct pi433_instance *instance;
> struct pi433_device *device;
> + struct pi433_tx_cfg tx_cfg_buffer;
> void __user *argp = (void __user *)arg;
>
> /* Check type and command number */
> @@ -902,9 +903,15 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> return -EFAULT;
> break;
> case PI433_IOC_WR_TX_CFG:
> - if (copy_from_user(&instance->tx_cfg, argp,
> - sizeof(struct pi433_tx_cfg)))
> + /* do not modify tx config while it is being copied to fifo */

There is no need for this comment, since it's obvious. Also if you use
simpler names then the copy fits on one line:

if (copy_from_user(&tx_cfg, argp, sizeof(tx_cfg)) {


> + mutex_lock(&device->tx_fifo_lock);
> + if (copy_from_user(&tx_cfg_buffer, argp,
> + sizeof(struct pi433_tx_cfg))) {

Sorry for the duplicate review, but it got sent to both my inboxes... :P

regards,
dan carpenter

\
 
 \ /
  Last update: 2018-06-13 11:17    [W:0.020 / U:1.464 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site