@@ -1612,9 +1612,6 @@ static int select_pmem_id(struct nd_region *nd_region, const uuid_t *pmem_id)
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 );
@@ -1790,9 +1787,6 @@ static struct device *create_namespace_pmem(struct nd_region *nd_region,
1790
1787
case - EINVAL :
1791
1788
dev_dbg (& nd_region -> dev , "invalid label(s)\n" );
1792
1789
break ;
1793
- case - ENODEV :
1794
- dev_dbg (& nd_region -> dev , "label not found\n" );
1795
- break ;
1796
1790
default :
1797
1791
dev_dbg (& nd_region -> dev , "unexpected err: %d\n" , rc );
1798
1792
break ;
@@ -1937,12 +1931,16 @@ static int cmp_dpa(const void *a, const void *b)
1937
1931
static struct device * * scan_labels (struct nd_region * nd_region )
1938
1932
{
1939
1933
int i , count = 0 ;
1940
- struct device * dev , * * devs = NULL ;
1934
+ struct device * dev , * * devs ;
1941
1935
struct nd_label_ent * label_ent , * e ;
1942
1936
struct nd_mapping * nd_mapping = & nd_region -> mapping [0 ];
1943
1937
struct nvdimm_drvdata * ndd = to_ndd (nd_mapping );
1944
1938
resource_size_t map_end = nd_mapping -> start + nd_mapping -> size - 1 ;
1945
1939
1940
+ devs = kcalloc (2 , sizeof (dev ), GFP_KERNEL );
1941
+ if (!devs )
1942
+ return NULL ;
1943
+
1946
1944
/* "safe" because create_namespace_pmem() might list_move() label_ent */
1947
1945
list_for_each_entry_safe (label_ent , e , & nd_mapping -> labels , list ) {
1948
1946
struct nd_namespace_label * nd_label = label_ent -> label ;
@@ -1961,22 +1959,21 @@ static struct device **scan_labels(struct nd_region *nd_region)
1961
1959
goto err ;
1962
1960
if (i < count )
1963
1961
continue ;
1964
- __devs = kcalloc (count + 2 , sizeof (dev ), GFP_KERNEL );
1965
- if (!__devs )
1966
- goto err ;
1967
- memcpy (__devs , devs , sizeof (dev ) * count );
1968
- kfree (devs );
1969
- devs = __devs ;
1962
+ if (count ) {
1963
+ __devs = kcalloc (count + 2 , sizeof (dev ), GFP_KERNEL );
1964
+ if (!__devs )
1965
+ goto err ;
1966
+ memcpy (__devs , devs , sizeof (dev ) * count );
1967
+ kfree (devs );
1968
+ devs = __devs ;
1969
+ }
1970
1970
1971
1971
dev = create_namespace_pmem (nd_region , nd_mapping , nd_label );
1972
1972
if (IS_ERR (dev )) {
1973
1973
switch (PTR_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
}
@@ -1993,11 +1990,6 @@ static struct device **scan_labels(struct nd_region *nd_region)
1993
1990
1994
1991
/* Publish a zero-sized namespace for userspace to configure. */
1995
1992
nd_mapping_free_labels (nd_mapping );
1996
-
1997
- devs = kcalloc (2 , sizeof (dev ), GFP_KERNEL );
1998
- if (!devs )
1999
- goto err ;
2000
-
2001
1993
nspm = kzalloc (sizeof (* nspm ), GFP_KERNEL );
2002
1994
if (!nspm )
2003
1995
goto err ;
@@ -2036,11 +2028,10 @@ static struct device **scan_labels(struct nd_region *nd_region)
2036
2028
return devs ;
2037
2029
2038
2030
err :
2039
- if (devs ) {
2040
- for (i = 0 ; devs [i ]; i ++ )
2041
- namespace_pmem_release (devs [i ]);
2042
- kfree (devs );
2043
- }
2031
+ for (i = 0 ; devs [i ]; i ++ )
2032
+ namespace_pmem_release (devs [i ]);
2033
+ kfree (devs );
2034
+
2044
2035
return NULL ;
2045
2036
}
2046
2037
0 commit comments