summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/nfit
diff options
context:
space:
mode:
authorToshi Kani <toshi.kani@hpe.com>2018-02-02 14:00:36 -0700
committerDan Williams <dan.j.williams@intel.com>2018-02-02 13:49:29 -0800
commit23fbd7c70aec7600e3227eb24259fc55bf6e4881 (patch)
tree55e8986f9632c035151cdfcaa5aeae32b5f08511 /drivers/acpi/nfit
parentf2ba5a5baecf795c2150826bd0c95fc3f7f3d226 (diff)
downloadlinux-23fbd7c70aec7600e3227eb24259fc55bf6e4881.tar.bz2
acpi, nfit: fix register dimm error handling
A NULL pointer reference kernel bug was observed when acpi_nfit_add_dimm() called in acpi_nfit_register_dimms() failed. This error path does not set nfit_mem->nvdimm, but the 2nd list_for_each_entry() loop in the function assumes it's always set. Add a check to nfit_mem->nvdimm. Cc: <stable@vger.kernel.org> Fixes: ba9c8dd3c222 ("acpi, nfit: add dimm device notification support") Signed-off-by: Toshi Kani <toshi.kani@hpe.com> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/acpi/nfit')
-rw-r--r--drivers/acpi/nfit/core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index ff2580e7611d..4af0f936147a 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1860,6 +1860,9 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
struct kernfs_node *nfit_kernfs;
nvdimm = nfit_mem->nvdimm;
+ if (!nvdimm)
+ continue;
+
nfit_kernfs = sysfs_get_dirent(nvdimm_kobj(nvdimm)->sd, "nfit");
if (nfit_kernfs)
nfit_mem->flags_attr = sysfs_get_dirent(nfit_kernfs,