selinux: simple cleanup for cond_read_node()
authorNamhyung Kim <namhyung@kernel.org>
Sat, 14 Jun 2014 16:19:01 +0000 (01:19 +0900)
committerPaul Moore <pmoore@redhat.com>
Thu, 19 Jun 2014 18:53:15 +0000 (14:53 -0400)
The node->cur_state and len can be read in a single call of next_entry().
And setting len before reading is a dead write so can be eliminated.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
(Minor tweak to the length parameter in the call to next_entry())
Signed-off-by: Paul Moore <pmoore@redhat.com>
security/selinux/ss/conditional.c

index 377d148e715743250c9836b7a5ca6c1a05fa98e0..f09cc7268b65bd9655445d30edb63b3e65906de2 100644 (file)
@@ -402,19 +402,14 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
        int rc;
        struct cond_expr *expr = NULL, *last = NULL;
 
-       rc = next_entry(buf, fp, sizeof(u32));
+       rc = next_entry(buf, fp, sizeof(u32) * 2);
        if (rc)
                return rc;
 
        node->cur_state = le32_to_cpu(buf[0]);
 
-       len = 0;
-       rc = next_entry(buf, fp, sizeof(u32));
-       if (rc)
-               return rc;
-
        /* expr */
-       len = le32_to_cpu(buf[0]);
+       len = le32_to_cpu(buf[1]);
 
        for (i = 0; i < len; i++) {
                rc = next_entry(buf, fp, sizeof(u32) * 2);