From: David Laight <David.Laight@ACULAB.COM>
To: 'Konrad Rzeszutek Wilk' <konrad.wilk@oracle.com>,
"alison.schofield@intel.com" <alison.schofield@intel.com>,
"vishal.l.verma@intel.com" <vishal.l.verma@intel.com>,
"ira.weiny@intel.com" <ira.weiny@intel.com>,
"ben.widawsky@intel.com" <ben.widawsky@intel.com>,
"dan.j.williams@intel.com" <dan.j.williams@intel.com>,
"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2] cxl: Make loop variable be 'i' instead of 'j'
Date: Mon, 1 Mar 2021 16:55:09 +0000 [thread overview]
Message-ID: <9c4643b7200449ce8e6693e4bcaf24b6@AcuMS.aculab.com> (raw)
In-Reply-To: <20210226211656.46359-1-konrad.wilk@oracle.com>
From: Konrad Rzeszutek Wilk
> Sent: 26 February 2021 21:17
>
> .. otherwise people spend extra cycles looking for the
> inner loop and wondering 'why j'?
>
> This was an oversight when initial work was rebased
> so let's fix it here.
>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
> v1: Initial posting
> v2: Fix per Dan's request
> ---
> drivers/cxl/mem.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
> index 244cb7d89678..d43197a193ce 100644
> --- a/drivers/cxl/mem.c
> +++ b/drivers/cxl/mem.c
> @@ -698,7 +698,6 @@ static int cxl_query_cmd(struct cxl_memdev *cxlmd,
> struct device *dev = &cxlmd->dev;
> struct cxl_mem_command *cmd;
> u32 n_commands;
> - int j = 0;
>
> dev_dbg(dev, "Query IOCTL\n");
>
> @@ -715,11 +714,12 @@ static int cxl_query_cmd(struct cxl_memdev *cxlmd,
> */
> cxl_for_each_cmd(cmd) {
> const struct cxl_command_info *info = &cmd->info;
> + int i = 0;
>
> - if (copy_to_user(&q->commands[j++], info, sizeof(*info)))
> + if (copy_to_user(&q->commands[i++], info, sizeof(*info)))
> return -EFAULT;
>
> - if (j == n_commands)
> + if (i == n_commands)
> break;
Did you test this?
Looks badly broken to me.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2021-03-01 17:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-26 20:45 [PATCH v1] Little fix that missed the merge window Konrad Rzeszutek Wilk
2021-02-26 20:45 ` [PATCH] cxl: Make loop variable be 'i' instead of 'j' Konrad Rzeszutek Wilk
2021-02-26 20:55 ` Dan Williams
2021-02-26 21:16 ` [PATCH v2] " Konrad Rzeszutek Wilk
2021-03-01 16:55 ` David Laight [this message]
2021-03-03 19:57 ` Konrad Rzeszutek Wilk
2021-02-26 22:21 ` [PATCH v3] " Konrad Rzeszutek Wilk
2021-02-26 20:55 ` [PATCH] " Al Viro
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=9c4643b7200449ce8e6693e4bcaf24b6@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=alison.schofield@intel.com \
--cc=ben.widawsky@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ira.weiny@intel.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vishal.l.verma@intel.com \
/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