aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2017-04-24 18:43:05 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-20 08:28:42 -0400
commit5b6e7f353290ca9b042090e0913caa71c2180d35 (patch)
tree70a40fd6556eb1eb5f696a6e48211e80a2fdb538
parent46ba11b007c1988cd12ac5f40224b4393689a86b (diff)
libnvdimm, region: fix flush hint detection crash
commit bc042fdfbb92b5b13421316b4548e2d6e98eed37 upstream. In the case where a dimm does not have any associated flush hints the ndrd->flush_wpq array may be uninitialized leading to crashes with the following signature: BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 IP: region_visible+0x10f/0x160 [libnvdimm] Call Trace: internal_create_group+0xbe/0x2f0 sysfs_create_groups+0x40/0x80 device_add+0x2d8/0x650 nd_async_device_register+0x12/0x40 [libnvdimm] async_run_entry_fn+0x39/0x170 process_one_work+0x212/0x6c0 ? process_one_work+0x197/0x6c0 worker_thread+0x4e/0x4a0 kthread+0x10c/0x140 ? process_one_work+0x6c0/0x6c0 ? kthread_create_on_node+0x60/0x60 ret_from_fork+0x31/0x40 Reviewed-by: Jeff Moyer <jmoyer@redhat.com> Fixes: f284a4f23752 ("libnvdimm: introduce nvdimm_flush() and nvdimm_has_flush()") Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/nvdimm/region_devs.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index 9cf6f1a88fce..f62306246ca4 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -968,17 +968,20 @@ EXPORT_SYMBOL_GPL(nvdimm_flush);
968 */ 968 */
969int nvdimm_has_flush(struct nd_region *nd_region) 969int nvdimm_has_flush(struct nd_region *nd_region)
970{ 970{
971 struct nd_region_data *ndrd = dev_get_drvdata(&nd_region->dev);
972 int i; 971 int i;
973 972
974 /* no nvdimm == flushing capability unknown */ 973 /* no nvdimm == flushing capability unknown */
975 if (nd_region->ndr_mappings == 0) 974 if (nd_region->ndr_mappings == 0)
976 return -ENXIO; 975 return -ENXIO;
977 976
978 for (i = 0; i < nd_region->ndr_mappings; i++) 977 for (i = 0; i < nd_region->ndr_mappings; i++) {
979 /* flush hints present, flushing required */ 978 struct nd_mapping *nd_mapping = &nd_region->mapping[i];
980 if (ndrd_get_flush_wpq(ndrd, i, 0)) 979 struct nvdimm *nvdimm = nd_mapping->nvdimm;
980
981 /* flush hints present / available */
982 if (nvdimm->num_flush)
981 return 1; 983 return 1;
984 }
982 985
983 /* 986 /*
984 * The platform defines dimm devices without hints, assume 987 * The platform defines dimm devices without hints, assume