Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3475327imu; Wed, 7 Nov 2018 10:53:22 -0800 (PST) X-Google-Smtp-Source: AJdET5c+s2ymR6SY1yR4akjMh7cM7IvsF2eRZrGPMLHrp78P5CNcAG5l8lYWjvU14JZX4k5IdcN2 X-Received: by 2002:a17:902:ab81:: with SMTP id f1-v6mr1401806plr.103.1541616802817; Wed, 07 Nov 2018 10:53:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541616802; cv=none; d=google.com; s=arc-20160816; b=eCFjq4MEzA5HFEr0QjPahmkTCV6mrxdK6Zyh7KHfuvXZb8bbOHUvRMzTee+IxewxzA wjgDIN0ECdISk3aWZ93ngAffxXS9XGMSQsSJdPzbI3GYfl1wctwhoWFZ/aIeYZpiR9Jq 05NZeNbZy2A5EMIIJiqupkcQRStkwpTJrAz3sTq+Xe6kl7gY/n01ZpT0x2dXiffl6XqH 1RobOPqQ40wIPqYCdjT0AeJfV4KhgmXJPIK/d15itEOpFUjfq0weTpVr/fLgLqwZ2bIm LH+gA3ewUZ1t2mkPO+OUNUyu+DnDahpxVdK0wfKeqjbRQ9cb6WyT9dKseqUDNQI8V3JK qQBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=1qqRp3fSWMeh/6If4YXOUGgZVVbhdquhwQW2s9Ni8Cw=; b=erRUK+/WrLIxsSDeiRb7MiTVE+ryJCxWLVq1veZVHv0lA4Zy8bM5gtqdul99/MrzUD +g551QbJ+GqEfZNTnv6Jk0dxvIuyWox4ut95QHDqo7Vcxx6jzwGnWNHejtv+ewYUFApP 2YJ0rjxGWHJ4PgoDPYxkBnmOaKOIDM8rJkvYfpZShwEmbY9Dum8Lrep3YJGUUOWLaKEY aBzfHlYPUmr1ELy78WN+m5hhJ44nIDYHluR4mpPqPP5WDnuy4kHBK0s/mMXTOcFJMmGZ yBZOjwakpelXZYZUmZtPfJMeL9fZlHoPemYwzzpPeF0PJxv6FKEPrA+vBE3nJKRxzHqm UfVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si1085736pgf.577.2018.11.07.10.53.06; Wed, 07 Nov 2018 10:53:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729382AbeKHEYY (ORCPT + 99 others); Wed, 7 Nov 2018 23:24:24 -0500 Received: from g9t1613g.houston.hpe.com ([15.241.32.99]:46311 "EHLO g9t1613g.houston.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726938AbeKHEYY (ORCPT ); Wed, 7 Nov 2018 23:24:24 -0500 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 1F053629BC; Wed, 7 Nov 2018 18:52:45 +0000 (UTC) Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3425.houston.hpe.com (Postfix) with ESMTP id 4F5C0B9; Wed, 7 Nov 2018 18:52:44 +0000 (UTC) Received: from misato.americas.hpqcorp.net (unknown [10.34.81.122]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id A5AFA48; Wed, 7 Nov 2018 18:52:43 +0000 (UTC) From: Toshi Kani To: dan.j.williams@intel.com Cc: vishal.l.verma@intel.com, dave.jiang@intel.com, elliott@hpe.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, Toshi Kani , stable@vger.kernel.org Subject: [PATCH] libnvdimm: Fix __nd_ioctl() to check error in cmd_rc Date: Wed, 7 Nov 2018 11:52:41 -0700 Message-Id: <20181107185241.26982-1-toshi.kani@hpe.com> X-Mailer: git-send-email 2.17.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ndctl zero-labels completes with a large number of zeroed nmems when it fails to do zeroing on a protected NVDIMM. # ndctl zero-labels nmem1 zeroed 65504 nmems When an ACPI call completes with error, xlat_status() called from acpi_nfit_ctl() sets error to *cmd_rc. __nd_ioctl(), however, does not check this error and returns with success. Fix __nd_ioctl() to check this error in cmd_rc. Fixes: 006358b35c73a ("libnvdimm: add support for clear poison list and badblocks for device dax") Reported-by: Robert Elliott Signed-off-by: Toshi Kani Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: --- drivers/nvdimm/bus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index f1fb39921236..af12817d8a02 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -1050,6 +1050,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm, rc = nd_desc->ndctl(nd_desc, nvdimm, cmd, buf, buf_len, &cmd_rc); if (rc < 0) goto out_unlock; + if (cmd_rc < 0) { + rc = cmd_rc; + goto out_unlock; + } if (!nvdimm && cmd == ND_CMD_CLEAR_ERROR && cmd_rc >= 0) { struct nd_cmd_clear_error *clear_err = buf;