All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: vishal.l.verma@intel.com, Luis Chamberlain <mcgrof@kernel.org>,
	linux-cxl@vger.kernel.org
Subject: Re: [PATCH 2/2] cxl/region: Fix memdev_filter_pos() separator detection
Date: Thu, 15 Dec 2022 20:06:45 -0800	[thread overview]
Message-ID: <Y5vu1QLspa+Lpucq@aschofie-mobl2> (raw)
In-Reply-To: <167106803771.1326377.10608704295797398750.stgit@dwillia2-xfh.jf.intel.com>

On Wed, Dec 14, 2022 at 05:33:57PM -0800, Dan Williams wrote:
> Stop using the modified version of the @_csv as the string to determine
> the separator it may cause which_sep() to get different answers each
> iteration. Moreover there is no need to retrieve the separator each
> iteration, so just retrieve it once from @_csv.
> 
> If the separator is mismatched it can lead to the sort not following the
> specified device order for create-region.
> 

Tested-by: Alison Schofield <alison.schofield@intel.com>

> Reported-by: Luis Chamberlain <mcgrof@kernel.org>
> Link: https://gist.github.com/mcgrof/aeac639365a651bd77f143cf38eb7493
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  cxl/region.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/cxl/region.c b/cxl/region.c
> index 2202afa440ef..bb3a10a7713c 100644
> --- a/cxl/region.c
> +++ b/cxl/region.c
> @@ -172,6 +172,7 @@ static struct sort_context {
>  static int memdev_filter_pos(struct json_object *jobj, const char *_csv)
>  {
>  	struct cxl_memdev *memdev = json_object_get_userdata(jobj);
> +	const char *sep = which_sep(_csv);
>  	char *csv, *save;
>  	const char *arg;
>  	int pos;
> @@ -180,8 +181,8 @@ static int memdev_filter_pos(struct json_object *jobj, const char *_csv)
>  	if (!csv)
>  		return -1;
>  
> -	for (pos = 0, arg = strtok_r(csv, which_sep(csv), &save); arg;
> -	     arg = strtok_r(NULL, which_sep(csv), &save), pos++)
> +	for (pos = 0, arg = strtok_r(csv, sep, &save); arg;
> +	     arg = strtok_r(NULL, sep, &save), pos++)
>  		if (util_cxl_memdev_filter(memdev, arg, NULL))
>  			break;
>  	free(csv);
> 

      reply	other threads:[~2022-12-16  4:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-15  1:33 [PATCH 0/2] cxl/region: Fix a couple memory safety bugs Dan Williams
2022-12-15  1:33 ` [PATCH 1/2] cxl/region: Fix memdev_filter_pos() memory leak Dan Williams
2022-12-16  4:08   ` Alison Schofield
2022-12-15  1:33 ` [PATCH 2/2] cxl/region: Fix memdev_filter_pos() separator detection Dan Williams
2022-12-16  4:06   ` Alison Schofield [this message]

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=Y5vu1QLspa+Lpucq@aschofie-mobl2 \
    --to=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=mcgrof@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.