staging: lustre: fix crash due to NULL networks string
[deliverable/linux.git] / drivers / staging / lustre / lnet / lnet / config.c
index 1ef07cdd5fe0769bb007786e852b5930ce14ac06..013d41b47c23729d9bdfc925a6b46c747c2e0d9b 100644 (file)
@@ -184,7 +184,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;
@@ -192,6 +192,11 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
        __u32 net;
        int nnets = 0;
 
+       if (!networks) {
+               CERROR("networks string is undefined\n");
+               return -EINVAL;
+       }
+
        if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) {
                /* _WAY_ conservative */
                LCONSOLE_ERROR_MSG(0x112,
@@ -199,6 +204,8 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
                return -EINVAL;
        }
 
+       tokensize = strlen(networks) + 1;
+
        LIBCFS_ALLOC(tokens, tokensize);
        if (!tokens) {
                CERROR("Can't allocate net tokens\n");
This page took 0.02857 seconds and 5 git commands to generate.