Whamcloud - gitweb
LU-1961 build: fix 'dereference before null check' errors
[fs/lustre-release.git] / lnet / selftest / conctl.c
index 6e11275..61c7242 100644 (file)
@@ -26,6 +26,8 @@
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -70,15 +72,15 @@ lst_session_new_ioctl(lstio_session_new_args_t *args)
 
         name[args->lstio_ses_nmlen] = 0;
 
-        rc = lstcon_session_new(name,
-                             args->lstio_ses_key,
-                             args->lstio_ses_timeout,
-                             args->lstio_ses_force,
-                             args->lstio_ses_idp);
-
-        LIBCFS_FREE(name, args->lstio_ses_nmlen + 1);
+       rc = lstcon_session_new(name,
+                               args->lstio_ses_key,
+                               args->lstio_ses_feats,
+                               args->lstio_ses_force,
+                               args->lstio_ses_timeout,
+                               args->lstio_ses_idp);
 
-        return rc;
+       LIBCFS_FREE(name, args->lstio_ses_nmlen + 1);
+       return rc;
 }
 
 int
@@ -97,6 +99,7 @@ lst_session_info_ioctl(lstio_session_info_args_t *args)
 
         if (args->lstio_ses_idp   == NULL || /* address for ouput sid */
             args->lstio_ses_keyp  == NULL || /* address for ouput key */
+           args->lstio_ses_featp  == NULL || /* address for ouput features */
             args->lstio_ses_ndinfo == NULL || /* address for output ndinfo */
             args->lstio_ses_namep == NULL || /* address for ouput name */
             args->lstio_ses_nmlen <= 0 ||
@@ -105,6 +108,7 @@ lst_session_info_ioctl(lstio_session_info_args_t *args)
 
         return lstcon_session_info(args->lstio_ses_idp,
                                    args->lstio_ses_keyp,
+                                  args->lstio_ses_featp,
                                    args->lstio_ses_ndinfo,
                                    args->lstio_ses_namep,
                                    args->lstio_ses_nmlen);
@@ -320,6 +324,7 @@ lst_group_update_ioctl(lstio_group_update_args_t *args)
 int
 lst_nodes_add_ioctl(lstio_group_nodes_args_t *args)
 {
+       unsigned feats;
         int     rc;
         char   *name;
 
@@ -329,8 +334,9 @@ lst_nodes_add_ioctl(lstio_group_nodes_args_t *args)
         if (args->lstio_grp_idsp == NULL || /* array of ids */
             args->lstio_grp_count <= 0 ||
             args->lstio_grp_resultp == NULL ||
-            args->lstio_grp_namep == NULL ||
-            args->lstio_grp_nmlen <= 0 || 
+           args->lstio_grp_featp == NULL ||
+           args->lstio_grp_namep == NULL ||
+           args->lstio_grp_nmlen <= 0 ||
             args->lstio_grp_nmlen > LST_NAME_SIZE)
                 return -EINVAL;
 
@@ -348,10 +354,14 @@ lst_nodes_add_ioctl(lstio_group_nodes_args_t *args)
         name[args->lstio_grp_nmlen] = 0;
 
         rc = lstcon_nodes_add(name, args->lstio_grp_count,
-                              args->lstio_grp_idsp,
-                              args->lstio_grp_resultp);
+                             args->lstio_grp_idsp, &feats,
+                             args->lstio_grp_resultp);
 
-        LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
+       LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
+       if (rc == 0 &&
+           cfs_copy_to_user(args->lstio_grp_featp, &feats, sizeof(feats))) {
+               return -EINVAL;
+       }
 
         return rc;
 }
@@ -734,6 +744,12 @@ int lst_test_add_ioctl(lstio_test_args_t *args)
             args->lstio_tes_dgrp_nmlen > LST_NAME_SIZE)
                 return -EINVAL;
 
+       if (args->lstio_tes_loop == 0 || /* negative is infinite */
+           args->lstio_tes_concur <= 0 ||
+           args->lstio_tes_dist <= 0 ||
+           args->lstio_tes_span <= 0)
+               return -EINVAL;
+
         /* have parameter, check if parameter length is valid */
         if (args->lstio_tes_param != NULL &&
             (args->lstio_tes_param_len <= 0 ||
@@ -749,7 +765,7 @@ int lst_test_add_ioctl(lstio_test_args_t *args)
                 goto out;
 
         LIBCFS_ALLOC(dstgrp, args->lstio_tes_dgrp_nmlen + 1);
-        if (srcgrp == NULL) 
+        if (dstgrp == NULL)
                 goto out;
 
         if (args->lstio_tes_param != NULL) {
@@ -822,7 +838,7 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data)
                 return -EFAULT;
         }
 
-        cfs_mutex_lock(&console_session.ses_mutex);
+       mutex_lock(&console_session.ses_mutex);
 
         console_session.ses_laststamp = cfs_time_current_sec();
 
@@ -906,7 +922,7 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data)
                              sizeof(lstcon_trans_stat_t)))
                 rc = -EFAULT;
 out:
-        cfs_mutex_unlock(&console_session.ses_mutex);
+       mutex_unlock(&console_session.ses_mutex);
 
         LIBCFS_FREE(buf, data->ioc_plen1);