All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Williams, Dan J" <dan.j.williams@intel.com>,
	"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>
Cc: "stable@vger.kernel.org" <stable@vger.kernel.org>,
	"Ye, Chris" <chris.ye@intel.com>
Subject: Re: [PATCH] nvdimm: Fix badblocks clear off-by-one error
Date: Wed, 1 Jun 2022 20:13:46 +0000	[thread overview]
Message-ID: <13af10d75e81206b2d70d9669685c373014ffaa9.camel@intel.com> (raw)
In-Reply-To: <165404219489.2445897.9792886413715690399.stgit@dwillia2-xfh>

On Tue, 2022-05-31 at 17:09 -0700, Dan Williams wrote:
> From: Chris Ye <chris.ye@intel.com>
> 
> nvdimm_clear_badblocks_region() validates badblock clearing requests
> against the span of the region, however it compares the inclusive
> badblock request range to the exclusive region range. Fix up the
> off-by-one error.
> 
> Fixes: 23f498448362 ("libnvdimm: rework region badblocks clearing")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Chris Ye <chris.ye@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  drivers/nvdimm/bus.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Good find! Looks good to me,

Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

> 
> diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
> index 7b0d1443217a..5db16857b80e 100644
> --- a/drivers/nvdimm/bus.c
> +++ b/drivers/nvdimm/bus.c
> @@ -182,8 +182,8 @@ static int nvdimm_clear_badblocks_region(struct
> device *dev, void *data)
>         ndr_end = nd_region->ndr_start + nd_region->ndr_size - 1;
>  
>         /* make sure we are in the region */
> -       if (ctx->phys < nd_region->ndr_start
> -                       || (ctx->phys + ctx->cleared) > ndr_end)
> +       if (ctx->phys < nd_region->ndr_start ||
> +           (ctx->phys + ctx->cleared - 1) > ndr_end)
>                 return 0;
>  
>         sector = (ctx->phys - nd_region->ndr_start) / 512;
> 
> 


      reply	other threads:[~2022-06-01 20:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-01  0:09 [PATCH] nvdimm: Fix badblocks clear off-by-one error Dan Williams
2022-06-01 20:13 ` Verma, Vishal L [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=13af10d75e81206b2d70d9669685c373014ffaa9.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=chris.ye@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /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.