Skip to content

Commit

Permalink
acpi, nfit: fix register dimm error handling
Browse files Browse the repository at this point in the history
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: ba9c8dd ("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>
  • Loading branch information
toshikani authored and djbw committed Feb 2, 2018
1 parent f2ba5a5 commit 23fbd7c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/acpi/nfit/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 23fbd7c

Please sign in to comment.