Commit 00b43f85 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull libnvdimm updates from Ira Weiny:

 - use Open Firmware helper routines

 - fix memory leak when nvdimm labels are incorrect

 - remove some dead code

* tag 'libnvdimm-for-6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
  nvdimm: Remove dead code for ENODEV checking in scan_labels()
  nvdimm: Fix devs leaks in scan_labels()
  nvdimm: Use of_property_present() and of_property_read_bool()
parents 20d9ba73 447b167b
...@@ -1612,9 +1612,6 @@ static int select_pmem_id(struct nd_region *nd_region, const uuid_t *pmem_id) ...@@ -1612,9 +1612,6 @@ static int select_pmem_id(struct nd_region *nd_region, const uuid_t *pmem_id)
{ {
int i; int i;
if (!pmem_id)
return -ENODEV;
for (i = 0; i < nd_region->ndr_mappings; i++) { for (i = 0; i < nd_region->ndr_mappings; i++) {
struct nd_mapping *nd_mapping = &nd_region->mapping[i]; struct nd_mapping *nd_mapping = &nd_region->mapping[i];
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping); struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
...@@ -1790,9 +1787,6 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region, ...@@ -1790,9 +1787,6 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
case -EINVAL: case -EINVAL:
dev_dbg(&nd_region->dev, "invalid label(s)\n"); dev_dbg(&nd_region->dev, "invalid label(s)\n");
break; break;
case -ENODEV:
dev_dbg(&nd_region->dev, "label not found\n");
break;
default: default:
dev_dbg(&nd_region->dev, "unexpected err: %d\n", rc); dev_dbg(&nd_region->dev, "unexpected err: %d\n", rc);
break; break;
...@@ -1937,12 +1931,16 @@ static int cmp_dpa(const void *a, const void *b) ...@@ -1937,12 +1931,16 @@ static int cmp_dpa(const void *a, const void *b)
static struct device **scan_labels(struct nd_region *nd_region) static struct device **scan_labels(struct nd_region *nd_region)
{ {
int i, count = 0; int i, count = 0;
struct device *dev, **devs = NULL; struct device *dev, **devs;
struct nd_label_ent *label_ent, *e; struct nd_label_ent *label_ent, *e;
struct nd_mapping *nd_mapping = &nd_region->mapping[0]; struct nd_mapping *nd_mapping = &nd_region->mapping[0];
struct nvdimm_drvdata *ndd = to_ndd(nd_mapping); struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
resource_size_t map_end = nd_mapping->start + nd_mapping->size - 1; resource_size_t map_end = nd_mapping->start + nd_mapping->size - 1;
devs = kcalloc(2, sizeof(dev), GFP_KERNEL);
if (!devs)
return NULL;
/* "safe" because create_namespace_pmem() might list_move() label_ent */ /* "safe" because create_namespace_pmem() might list_move() label_ent */
list_for_each_entry_safe(label_ent, e, &nd_mapping->labels, list) { list_for_each_entry_safe(label_ent, e, &nd_mapping->labels, list) {
struct nd_namespace_label *nd_label = label_ent->label; struct nd_namespace_label *nd_label = label_ent->label;
...@@ -1961,12 +1959,14 @@ static struct device **scan_labels(struct nd_region *nd_region) ...@@ -1961,12 +1959,14 @@ static struct device **scan_labels(struct nd_region *nd_region)
goto err; goto err;
if (i < count) if (i < count)
continue; continue;
if (count) {
__devs = kcalloc(count + 2, sizeof(dev), GFP_KERNEL); __devs = kcalloc(count + 2, sizeof(dev), GFP_KERNEL);
if (!__devs) if (!__devs)
goto err; goto err;
memcpy(__devs, devs, sizeof(dev) * count); memcpy(__devs, devs, sizeof(dev) * count);
kfree(devs); kfree(devs);
devs = __devs; devs = __devs;
}
dev = create_namespace_pmem(nd_region, nd_mapping, nd_label); dev = create_namespace_pmem(nd_region, nd_mapping, nd_label);
if (IS_ERR(dev)) { if (IS_ERR(dev)) {
...@@ -1974,9 +1974,6 @@ static struct device **scan_labels(struct nd_region *nd_region) ...@@ -1974,9 +1974,6 @@ static struct device **scan_labels(struct nd_region *nd_region)
case -EAGAIN: case -EAGAIN:
/* skip invalid labels */ /* skip invalid labels */
continue; continue;
case -ENODEV:
/* fallthrough to seed creation */
break;
default: default:
goto err; goto err;
} }
...@@ -1993,11 +1990,6 @@ static struct device **scan_labels(struct nd_region *nd_region) ...@@ -1993,11 +1990,6 @@ static struct device **scan_labels(struct nd_region *nd_region)
/* Publish a zero-sized namespace for userspace to configure. */ /* Publish a zero-sized namespace for userspace to configure. */
nd_mapping_free_labels(nd_mapping); nd_mapping_free_labels(nd_mapping);
devs = kcalloc(2, sizeof(dev), GFP_KERNEL);
if (!devs)
goto err;
nspm = kzalloc(sizeof(*nspm), GFP_KERNEL); nspm = kzalloc(sizeof(*nspm), GFP_KERNEL);
if (!nspm) if (!nspm)
goto err; goto err;
...@@ -2036,11 +2028,10 @@ static struct device **scan_labels(struct nd_region *nd_region) ...@@ -2036,11 +2028,10 @@ static struct device **scan_labels(struct nd_region *nd_region)
return devs; return devs;
err: err:
if (devs) {
for (i = 0; devs[i]; i++) for (i = 0; devs[i]; i++)
namespace_pmem_release(devs[i]); namespace_pmem_release(devs[i]);
kfree(devs); kfree(devs);
}
return NULL; return NULL;
} }
......
...@@ -47,7 +47,7 @@ static int of_pmem_region_probe(struct platform_device *pdev) ...@@ -47,7 +47,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
} }
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
is_volatile = !!of_find_property(np, "volatile", NULL); is_volatile = of_property_read_bool(np, "volatile");
dev_dbg(&pdev->dev, "Registering %s regions from %pOF\n", dev_dbg(&pdev->dev, "Registering %s regions from %pOF\n",
is_volatile ? "volatile" : "non-volatile", np); is_volatile ? "volatile" : "non-volatile", np);
......
...@@ -123,7 +123,7 @@ static int nvmem_layout_bus_populate(struct nvmem_device *nvmem, ...@@ -123,7 +123,7 @@ static int nvmem_layout_bus_populate(struct nvmem_device *nvmem,
int ret; int ret;
/* Make sure it has a compatible property */ /* Make sure it has a compatible property */
if (!of_get_property(layout_dn, "compatible", NULL)) { if (!of_property_present(layout_dn, "compatible")) {
pr_debug("%s() - skipping %pOF, no compatible prop\n", pr_debug("%s() - skipping %pOF, no compatible prop\n",
__func__, layout_dn); __func__, layout_dn);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment