Whamcloud - gitweb
LU-5928 obdclass: fix export of nodemap to procfs
[fs/lustre-release.git] / lnet / lnet / config.c
index 7dd588e..6cc64be 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -197,7 +197,7 @@ int
 lnet_parse_networks(struct list_head *nilist, char *networks)
 {
        struct cfs_expr_list *el = NULL;
-       int             tokensize = strlen(networks) + 1;
+       int             tokensize;
        char            *tokens;
        char            *str;
        char            *tmp;
@@ -205,6 +205,11 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
        __u32           net;
        int             nnets = 0;
 
+       if (networks == NULL) {
+               CERROR("networks string is undefined\n");
+               return -EINVAL;
+       }
+
        if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) {
                /* _WAY_ conservative */
                LCONSOLE_ERROR_MSG(0x112, "Can't parse networks: string too "
@@ -212,6 +217,8 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                return -EINVAL;
        }
 
+       tokensize = strlen(networks) + 1;
+
        LIBCFS_ALLOC(tokens, tokensize);
        if (tokens == NULL) {
                CERROR("Can't allocate net tokens\n");