]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
tools/testing/nvdimm: unit test clear-error commands
authorDan Williams <dan.j.williams@intel.com>
Sun, 12 Nov 2017 22:54:23 +0000 (14:54 -0800)
committerDan Williams <dan.j.williams@intel.com>
Mon, 13 Nov 2017 23:28:41 +0000 (15:28 -0800)
Validate command parsing in acpi_nfit_ctl for the clear error command.
This tests for a crash condition introduced by commit 4b27db7e26cd
"acpi, nfit: add support for the _LSI, _LSR, and _LSW label methods".

Cc: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
tools/testing/nvdimm/test/nfit.c

index edab68c2e2215724966215607a434a6e6baf1786..7217b2b953b588a662d287d83a1e7e8920ebca59 100644 (file)
@@ -1812,6 +1812,7 @@ static int nfit_ctl_test(struct device *dev)
        unsigned long mask, cmd_size, offset;
        union {
                struct nd_cmd_get_config_size cfg_size;
+               struct nd_cmd_clear_error clear_err;
                struct nd_cmd_ars_status ars_stat;
                struct nd_cmd_ars_cap ars_cap;
                char buf[sizeof(struct nd_cmd_ars_status)
@@ -1995,6 +1996,23 @@ static int nfit_ctl_test(struct device *dev)
                return -EIO;
        }
 
+       /* test clear error */
+       cmd_size = sizeof(cmds.clear_err);
+       cmds.clear_err = (struct nd_cmd_clear_error) {
+               .length = 512,
+               .cleared = 512,
+       };
+       rc = setup_result(cmds.buf, cmd_size);
+       if (rc)
+               return rc;
+       rc = acpi_nfit_ctl(&acpi_desc->nd_desc, NULL, ND_CMD_CLEAR_ERROR,
+                       cmds.buf, cmd_size, &cmd_rc);
+       if (rc < 0 || cmd_rc) {
+               dev_dbg(dev, "%s: failed at: %d rc: %d cmd_rc: %d\n",
+                               __func__, __LINE__, rc, cmd_rc);
+               return -EIO;
+       }
+
        return 0;
 }