Merge tag 'libnvdimm-for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm

Pull libnvdimm updates from Ira Weiny:
"Most of the code changes are to remove dead code.

The bug fixes are minor, Syzkaller and one for broken devices which
are unlikely to be in the field. So no need to backport them.

- two patches to remove dead code: nd_attach_ndns() and
nd_region_conflict() have not been used since 2017 and 2019
respectively

- Fix divide-by-0 if device returns a broken LSA value

- Fix Syzkaller reported bug"

* tag 'libnvdimm-for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
libnvdimm/labels: Fix divide error in nd_label_data_init()
libnvdimm: Remove unused nd_attach_ndns
libnvdimm: Remove unused nd_region_conflict
acpi: nfit: fix narrowing conversion in acpi_nfit_ctl

+3 -58
+1 -1
drivers/acpi/nfit/core.c
··· 485 cmd_mask = nd_desc->cmd_mask; 486 if (cmd == ND_CMD_CALL && call_pkg->nd_family) { 487 family = call_pkg->nd_family; 488 - if (family > NVDIMM_BUS_FAMILY_MAX || 489 !test_bit(family, &nd_desc->bus_family_mask)) 490 return -EINVAL; 491 family = array_index_nospec(family,
··· 485 cmd_mask = nd_desc->cmd_mask; 486 if (cmd == ND_CMD_CALL && call_pkg->nd_family) { 487 family = call_pkg->nd_family; 488 + if (call_pkg->nd_family > NVDIMM_BUS_FAMILY_MAX || 489 !test_bit(family, &nd_desc->bus_family_mask)) 490 return -EINVAL; 491 family = array_index_nospec(family,
-11
drivers/nvdimm/claim.c
··· 56 return true; 57 } 58 59 - bool nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach, 60 - struct nd_namespace_common **_ndns) 61 - { 62 - bool claimed; 63 - 64 - nvdimm_bus_lock(&attach->dev); 65 - claimed = __nd_attach_ndns(dev, attach, _ndns); 66 - nvdimm_bus_unlock(&attach->dev); 67 - return claimed; 68 - } 69 - 70 static bool is_idle(struct device *dev, struct nd_namespace_common *ndns) 71 { 72 struct nd_region *nd_region = to_nd_region(dev->parent);
··· 56 return true; 57 } 58 59 static bool is_idle(struct device *dev, struct nd_namespace_common *ndns) 60 { 61 struct nd_region *nd_region = to_nd_region(dev->parent);
+2 -1
drivers/nvdimm/label.c
··· 442 if (ndd->data) 443 return 0; 444 445 - if (ndd->nsarea.status || ndd->nsarea.max_xfer == 0) { 446 dev_dbg(ndd->dev, "failed to init config data area: (%u:%u)\n", 447 ndd->nsarea.max_xfer, ndd->nsarea.config_size); 448 return -ENXIO;
··· 442 if (ndd->data) 443 return 0; 444 445 + if (ndd->nsarea.status || ndd->nsarea.max_xfer == 0 || 446 + ndd->nsarea.config_size == 0) { 447 dev_dbg(ndd->dev, "failed to init config data area: (%u:%u)\n", 448 ndd->nsarea.max_xfer, ndd->nsarea.config_size); 449 return -ENXIO;
-4
drivers/nvdimm/nd-core.h
··· 127 resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region, 128 struct nd_mapping *nd_mapping); 129 resource_size_t nd_region_available_dpa(struct nd_region *nd_region); 130 - int nd_region_conflict(struct nd_region *nd_region, resource_size_t start, 131 - resource_size_t size); 132 resource_size_t nvdimm_allocated_dpa(struct nvdimm_drvdata *ndd, 133 struct nd_label_id *label_id); 134 int nvdimm_num_label_slots(struct nvdimm_drvdata *ndd); ··· 134 resource_size_t __nvdimm_namespace_capacity(struct nd_namespace_common *ndns); 135 void nd_detach_ndns(struct device *dev, struct nd_namespace_common **_ndns); 136 void __nd_detach_ndns(struct device *dev, struct nd_namespace_common **_ndns); 137 - bool nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach, 138 - struct nd_namespace_common **_ndns); 139 bool __nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach, 140 struct nd_namespace_common **_ndns); 141 ssize_t nd_namespace_store(struct device *dev,
··· 127 resource_size_t nd_pmem_available_dpa(struct nd_region *nd_region, 128 struct nd_mapping *nd_mapping); 129 resource_size_t nd_region_available_dpa(struct nd_region *nd_region); 130 resource_size_t nvdimm_allocated_dpa(struct nvdimm_drvdata *ndd, 131 struct nd_label_id *label_id); 132 int nvdimm_num_label_slots(struct nvdimm_drvdata *ndd); ··· 136 resource_size_t __nvdimm_namespace_capacity(struct nd_namespace_common *ndns); 137 void nd_detach_ndns(struct device *dev, struct nd_namespace_common **_ndns); 138 void __nd_detach_ndns(struct device *dev, struct nd_namespace_common **_ndns); 139 bool __nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach, 140 struct nd_namespace_common **_ndns); 141 ssize_t nd_namespace_store(struct device *dev,
-41
drivers/nvdimm/region_devs.c
··· 1229 } 1230 EXPORT_SYMBOL_GPL(is_nvdimm_sync); 1231 1232 - struct conflict_context { 1233 - struct nd_region *nd_region; 1234 - resource_size_t start, size; 1235 - }; 1236 - 1237 - static int region_conflict(struct device *dev, void *data) 1238 - { 1239 - struct nd_region *nd_region; 1240 - struct conflict_context *ctx = data; 1241 - resource_size_t res_end, region_end, region_start; 1242 - 1243 - if (!is_memory(dev)) 1244 - return 0; 1245 - 1246 - nd_region = to_nd_region(dev); 1247 - if (nd_region == ctx->nd_region) 1248 - return 0; 1249 - 1250 - res_end = ctx->start + ctx->size; 1251 - region_start = nd_region->ndr_start; 1252 - region_end = region_start + nd_region->ndr_size; 1253 - if (ctx->start >= region_start && ctx->start < region_end) 1254 - return -EBUSY; 1255 - if (res_end > region_start && res_end <= region_end) 1256 - return -EBUSY; 1257 - return 0; 1258 - } 1259 - 1260 - int nd_region_conflict(struct nd_region *nd_region, resource_size_t start, 1261 - resource_size_t size) 1262 - { 1263 - struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&nd_region->dev); 1264 - struct conflict_context ctx = { 1265 - .nd_region = nd_region, 1266 - .start = start, 1267 - .size = size, 1268 - }; 1269 - 1270 - return device_for_each_child(&nvdimm_bus->dev, &ctx, region_conflict); 1271 - } 1272 - 1273 MODULE_IMPORT_NS("DEVMEM");
··· 1229 } 1230 EXPORT_SYMBOL_GPL(is_nvdimm_sync); 1231 1232 MODULE_IMPORT_NS("DEVMEM");