From: Dan Carpenter <dan.carpenter@oracle.com>
To: Hugo Lefeuvre <hle@owl.eu.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org,
Marcus Wolf <linux@wolf-entwicklungen.de>,
linux-kernel@vger.kernel.org, kernelnewbies@kernelnewbies.org
Subject: Re: [PATCH v2] staging: pi433: fix race condition in pi433_ioctl
Date: Wed, 13 Jun 2018 12:16:49 +0300 [thread overview]
Message-ID: <20180613091649.r3bck3wjma6tmjet@mwanda> (raw)
In-Reply-To: <20180613014741.GC2265@hle-laptop.local>
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
next prev parent reply other threads:[~2018-06-13 9:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 1:47 [PATCH v2] staging: pi433: fix race condition in pi433_ioctl Hugo Lefeuvre
2018-06-13 9:08 ` Dan Carpenter
2018-06-13 9:16 ` Dan Carpenter [this message]
2018-06-14 1:10 ` Hugo Lefeuvre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180613091649.r3bck3wjma6tmjet@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hle@owl.eu.com \
--cc=kernelnewbies@kernelnewbies.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@wolf-entwicklungen.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox