The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.8.x-ovz" and will appear 
at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.8.4
------>
commit f9c9089662c033a8044d1fa9ff375ff0c2031b66
Author: Stanislav Kinsburskiy <[email protected]>
Date:   Thu Oct 8 15:53:17 2015 +0400

    ub stat: commnad check helper introduced
    
    Signed-off-by: Stanislav Kinsburskiy <[email protected]>
---
 kernel/bc/statd.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/kernel/bc/statd.c b/kernel/bc/statd.c
index b421ac1..db9f294 100644
--- a/kernel/bc/statd.c
+++ b/kernel/bc/statd.c
@@ -224,12 +224,29 @@ int ubstat_alloc_store(struct user_beancounter *ub)
 }
 EXPORT_SYMBOL(ubstat_alloc_store);
 
+static int ubstat_check_cmd(long cmd)
+{
+       switch (UBSTAT_CMD(cmd)) {
+               case UBSTAT_READ_ONE:
+                       if (UBSTAT_PARMID(cmd) >= UB_RESOURCES)
+                               break;
+               case UBSTAT_READ_ALL:
+               case UBSTAT_READ_FULL:
+                       return 0;
+       }
+       return -EINVAL;
+}
+
 static int ubstat_get_stat(struct user_beancounter *ub, long cmd,
                void __user *buf, long size)
 {
        void *kbuf;
        int retval;
 
+       retval = ubstat_check_cmd(cmd);
+       if (retval)
+               return retval;
+
        kbuf = (void *)__get_free_page(GFP_KERNEL);
        if (kbuf == NULL)
                return -ENOMEM;
@@ -241,9 +258,6 @@ static int ubstat_get_stat(struct user_beancounter *ub, 
long cmd,
        spin_lock(&ubs_notify_lock);
        switch (UBSTAT_CMD(cmd)) {
                case UBSTAT_READ_ONE:
-                       retval = -EINVAL;
-                       if (UBSTAT_PARMID(cmd) >= UB_RESOURCES)
-                               break;
                        retval = ubstat_do_read_one(ub,
                                        UBSTAT_PARMID(cmd), kbuf);
                        break;
@@ -255,6 +269,8 @@ static int ubstat_get_stat(struct user_beancounter *ub, 
long cmd,
                        break;
                default:
                        retval = -EINVAL;
+                       __WARN_printf("%s: we shouldn't get there\ncmd: %ld\n",
+                                       __func__, UBSTAT_CMD(cmd));
        }
        spin_unlock(&ubs_notify_lock);
 
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to