Commit ee6581ce authored by Dave Jiang's avatar Dave Jiang

nfit: fix unchecked dereference in acpi_nfit_ctl

Incremental patch to fix the unchecked dereference in acpi_nfit_ctl.
Reported by Dan Carpenter:

"acpi/nfit: fix cmd_rc for acpi_nfit_ctl to
always return a value" from Jun 28, 2018, leads to the following
Smatch complaint:

    drivers/acpi/nfit/core.c:578 acpi_nfit_ctl()
     warn: variable dereferenced before check 'cmd_rc' (see line 411)

drivers/acpi/nfit/core.c
   410
   411		*cmd_rc = -EINVAL;
                ^^^^^^^^^^^^^^^^^^
Patch adds unchecked dereference.

Fixes: c1985cef ("acpi/nfit: fix cmd_rc for acpi_nfit_ctl to always return a value")
Signed-off-by: default avatarDave Jiang <dave.jiang@intel.com>
parent 33cc2c96
...@@ -408,6 +408,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, ...@@ -408,6 +408,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
const guid_t *guid; const guid_t *guid;
int rc, i; int rc, i;
if (cmd_rc)
*cmd_rc = -EINVAL; *cmd_rc = -EINVAL;
func = cmd; func = cmd;
if (cmd == ND_CMD_CALL) { if (cmd == ND_CMD_CALL) {
...@@ -519,6 +520,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, ...@@ -519,6 +520,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
* If we return an error (like elsewhere) then caller wouldn't * If we return an error (like elsewhere) then caller wouldn't
* be able to rely upon data returned to make calculation. * be able to rely upon data returned to make calculation.
*/ */
if (cmd_rc)
*cmd_rc = 0; *cmd_rc = 0;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment