Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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()

+19 -28
+17 -26
drivers/nvdimm/namespace_devs.c
··· 1612 1612 { 1613 1613 int i; 1614 1614 1615 - if (!pmem_id) 1616 - return -ENODEV; 1617 - 1618 1615 for (i = 0; i < nd_region->ndr_mappings; i++) { 1619 1616 struct nd_mapping *nd_mapping = &nd_region->mapping[i]; 1620 1617 struct nvdimm_drvdata *ndd = to_ndd(nd_mapping); ··· 1787 1790 case -EINVAL: 1788 1791 dev_dbg(&nd_region->dev, "invalid label(s)\n"); 1789 1792 break; 1790 - case -ENODEV: 1791 - dev_dbg(&nd_region->dev, "label not found\n"); 1792 - break; 1793 1793 default: 1794 1794 dev_dbg(&nd_region->dev, "unexpected err: %d\n", rc); 1795 1795 break; ··· 1931 1937 static struct device **scan_labels(struct nd_region *nd_region) 1932 1938 { 1933 1939 int i, count = 0; 1934 - struct device *dev, **devs = NULL; 1940 + struct device *dev, **devs; 1935 1941 struct nd_label_ent *label_ent, *e; 1936 1942 struct nd_mapping *nd_mapping = &nd_region->mapping[0]; 1937 1943 struct nvdimm_drvdata *ndd = to_ndd(nd_mapping); 1938 1944 resource_size_t map_end = nd_mapping->start + nd_mapping->size - 1; 1945 + 1946 + devs = kcalloc(2, sizeof(dev), GFP_KERNEL); 1947 + if (!devs) 1948 + return NULL; 1939 1949 1940 1950 /* "safe" because create_namespace_pmem() might list_move() label_ent */ 1941 1951 list_for_each_entry_safe(label_ent, e, &nd_mapping->labels, list) { ··· 1959 1961 goto err; 1960 1962 if (i < count) 1961 1963 continue; 1962 - __devs = kcalloc(count + 2, sizeof(dev), GFP_KERNEL); 1963 - if (!__devs) 1964 - goto err; 1965 - memcpy(__devs, devs, sizeof(dev) * count); 1966 - kfree(devs); 1967 - devs = __devs; 1964 + if (count) { 1965 + __devs = kcalloc(count + 2, sizeof(dev), GFP_KERNEL); 1966 + if (!__devs) 1967 + goto err; 1968 + memcpy(__devs, devs, sizeof(dev) * count); 1969 + kfree(devs); 1970 + devs = __devs; 1971 + } 1968 1972 1969 1973 dev = create_namespace_pmem(nd_region, nd_mapping, nd_label); 1970 1974 if (IS_ERR(dev)) { ··· 1974 1974 case -EAGAIN: 1975 1975 /* skip invalid labels */ 1976 1976 continue; 1977 - case -ENODEV: 1978 - /* fallthrough to seed creation */ 1979 - break; 1980 1977 default: 1981 1978 goto err; 1982 1979 } ··· 1990 1993 1991 1994 /* Publish a zero-sized namespace for userspace to configure. */ 1992 1995 nd_mapping_free_labels(nd_mapping); 1993 - 1994 - devs = kcalloc(2, sizeof(dev), GFP_KERNEL); 1995 - if (!devs) 1996 - goto err; 1997 - 1998 1996 nspm = kzalloc(sizeof(*nspm), GFP_KERNEL); 1999 1997 if (!nspm) 2000 1998 goto err; ··· 2028 2036 return devs; 2029 2037 2030 2038 err: 2031 - if (devs) { 2032 - for (i = 0; devs[i]; i++) 2033 - namespace_pmem_release(devs[i]); 2034 - kfree(devs); 2035 - } 2039 + for (i = 0; devs[i]; i++) 2040 + namespace_pmem_release(devs[i]); 2041 + kfree(devs); 2042 + 2036 2043 return NULL; 2037 2044 } 2038 2045
+1 -1
drivers/nvdimm/of_pmem.c
··· 47 47 } 48 48 platform_set_drvdata(pdev, priv); 49 49 50 - is_volatile = !!of_find_property(np, "volatile", NULL); 50 + is_volatile = of_property_read_bool(np, "volatile"); 51 51 dev_dbg(&pdev->dev, "Registering %s regions from %pOF\n", 52 52 is_volatile ? "volatile" : "non-volatile", np); 53 53
+1 -1
drivers/nvmem/layouts.c
··· 123 123 int ret; 124 124 125 125 /* Make sure it has a compatible property */ 126 - if (!of_get_property(layout_dn, "compatible", NULL)) { 126 + if (!of_property_present(layout_dn, "compatible")) { 127 127 pr_debug("%s() - skipping %pOF, no compatible prop\n", 128 128 __func__, layout_dn); 129 129 return 0;