Commit 1a1e76c0 authored by Frederic Saunier's avatar Frederic Saunier Committed by Greg Kroah-Hartman

staging: lustre: remove last entry of libcfs_netstrfns[]

Currently NID string handling test for the last entry,
and last entry has .nf_type == (__u32) -1. If we ask
for a non existent LND we hit the last entry which then
calls a strlen on a NULL which causes a error. We can
avoid this problem if we just remove the last entry
since it is not used for anything except as a last
entry marker.
Signed-off-by: default avatarFrederic Saunier <frederic.saunier@atos.net>
Signed-off-by: default avatarJames Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6501
Reviewed-on: http://review.whamcloud.com/15424Reviewed-by: default avatarfrank zago <fzago@cray.com>
Reviewed-by: default avatarDmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 80feb1ef
...@@ -1101,8 +1101,6 @@ static struct netstrfns libcfs_netstrfns[] = { ...@@ -1101,8 +1101,6 @@ static struct netstrfns libcfs_netstrfns[] = {
/* .nf_match_addr*/ libcfs_num_match, /* .nf_match_addr*/ libcfs_num_match,
/* .nf_is_contiguous */ cfs_num_is_contiguous, /* .nf_is_contiguous */ cfs_num_is_contiguous,
/* .nf_min_max */ cfs_num_min_max}, /* .nf_min_max */ cfs_num_min_max},
/* placeholder for net0 alias. It MUST BE THE LAST ENTRY */
{/* .nf_type */ -1},
}; };
static const size_t libcfs_nnetstrfns = ARRAY_SIZE(libcfs_netstrfns); static const size_t libcfs_nnetstrfns = ARRAY_SIZE(libcfs_netstrfns);
...@@ -1127,8 +1125,7 @@ libcfs_namenum2netstrfns(const char *name) ...@@ -1127,8 +1125,7 @@ libcfs_namenum2netstrfns(const char *name)
for (i = 0; i < libcfs_nnetstrfns; i++) { for (i = 0; i < libcfs_nnetstrfns; i++) {
nf = &libcfs_netstrfns[i]; nf = &libcfs_netstrfns[i];
if (nf->nf_type >= 0 && if (!strncmp(name, nf->nf_name, strlen(nf->nf_name)))
!strncmp(name, nf->nf_name, strlen(nf->nf_name)))
return nf; return nf;
} }
return NULL; return NULL;
...@@ -1140,8 +1137,7 @@ libcfs_name2netstrfns(const char *name) ...@@ -1140,8 +1137,7 @@ libcfs_name2netstrfns(const char *name)
int i; int i;
for (i = 0; i < libcfs_nnetstrfns; i++) for (i = 0; i < libcfs_nnetstrfns; i++)
if (libcfs_netstrfns[i].nf_type >= 0 && if (!strcmp(libcfs_netstrfns[i].nf_name, name))
!strcmp(libcfs_netstrfns[i].nf_name, name))
return &libcfs_netstrfns[i]; return &libcfs_netstrfns[i];
return NULL; return NULL;
...@@ -1254,8 +1250,7 @@ libcfs_str2net_internal(const char *str, __u32 *net) ...@@ -1254,8 +1250,7 @@ libcfs_str2net_internal(const char *str, __u32 *net)
for (i = 0; i < libcfs_nnetstrfns; i++) { for (i = 0; i < libcfs_nnetstrfns; i++) {
nf = &libcfs_netstrfns[i]; nf = &libcfs_netstrfns[i];
if (nf->nf_type >= 0 && if (!strncmp(str, nf->nf_name, strlen(nf->nf_name)))
!strncmp(str, nf->nf_name, strlen(nf->nf_name)))
break; break;
} }
......
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