diff mbox

[v2] acpi/nfit: fix cmd_rc for acpi_nfit_ctl to always return a value

Message ID 153132483983.35487.460701028810915794.stgit@djiang5-desk3.ch.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dave Jiang July 11, 2018, 4:01 p.m. UTC
cmd_rc is passed in by reference to the acpi_nfit_ctl() function and the
caller expects a value returned. However, when the package is pass through
via the ND_CMD_CALL command, cmd_rc is not touched. Make sure cmd_rc is
always set.

Fixes: aef253382266 ("libnvdimm, nfit: centralize command status translation")

Signed-off-by: Dave Jiang <dave.jiang@intel.com>

- Fix unchecked dereference (Dan Carpenter)

 drivers/acpi/nfit/core.c |    4 ++++
 1 file changed, 4 insertions(+)
diff mbox


diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 7327b6a11ca9..0f47917b8ef1 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -408,6 +408,8 @@  int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
 	const guid_t *guid;
 	int rc, i;
+	if (cmd_rc)
+		*cmd_rc = -EINVAL;
 	func = cmd;
 	if (cmd == ND_CMD_CALL) {
 		call_pkg = buf;
@@ -518,6 +520,8 @@  int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
 		 * If we return an error (like elsewhere) then caller wouldn't
 		 * be able to rely upon data returned to make calculation.
+		if (cmd_rc)
+			*cmd_rc = 0;
 		return 0;