From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g9t1613g.houston.hpe.com ([15.241.32.99]:29495 "EHLO g9t1613g.houston.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932227AbdERO7v (ORCPT ); Thu, 18 May 2017 10:59:51 -0400 Received: from g4t3425.houston.hpe.com (g4t3425.houston.hpe.com [15.241.140.78]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by g9t1613g.houston.hpe.com (Postfix) with ESMTPS id 52A92606F2 for ; Thu, 18 May 2017 14:59:45 +0000 (UTC) From: Toshi Kani To: stable@vger.kernel.org Cc: dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, Toshi Kani Subject: [PATCH] libnvdimm: fix clear length of nvdimm_clear_from_poison_list() Date: Thu, 18 May 2017 08:59:28 -0600 Message-Id: <20170518145928.3221-1-toshi.kani@hpe.com> Sender: stable-owner@vger.kernel.org List-ID: ND_CMD_CLEAR_ERROR command returns 'clear_err.cleared', the length of error actually cleared, which may be smaller than its requested 'len'. Change nvdimm_clear_poison() to call nvdimm_clear_from_poison_list() with 'clear_err.cleared' when this value is valid. Cc: Fixes: e046114af5fc ("libnvdimm: clear the internal poison_list when clearing badblocks") Cc: Dave Jiang Cc: Vishal Verma Signed-off-by: Toshi Kani Signed-off-by: Dan Williams --- backport original commit 8d13c0290655b883df9083a2a0af0d782bc38aef --- drivers/nvdimm/bus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 351bac8..0392eb8 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -218,7 +218,10 @@ long nvdimm_clear_poison(struct device *dev, phys_addr_t phys, if (cmd_rc < 0) return cmd_rc; - nvdimm_clear_from_poison_list(nvdimm_bus, phys, len); + if (clear_err.cleared > 0) + nvdimm_clear_from_poison_list(nvdimm_bus, phys, + clear_err.cleared); + return clear_err.cleared; } EXPORT_SYMBOL_GPL(nvdimm_clear_poison);