{
char *key = NULL;
struct cond_bool_datum *booldatum;
- __u32 *buf, len;
+ u32 buf[3], len;
+ int rc;
booldatum = kmalloc(sizeof(struct cond_bool_datum), GFP_KERNEL);
if (!booldatum)
return -1;
memset(booldatum, 0, sizeof(struct cond_bool_datum));
- buf = next_entry(fp, sizeof(__u32) * 3);
- if (!buf)
+ rc = next_entry(buf, fp, sizeof buf);
+ if (rc < 0)
goto err;
booldatum->value = le32_to_cpu(buf[0]);
len = le32_to_cpu(buf[2]);
- buf = next_entry(fp, len);
- if (!buf)
- goto err;
key = kmalloc(len + 1, GFP_KERNEL);
if (!key)
goto err;
- memcpy(key, buf, len);
+ rc = next_entry(key, fp, len);
+ if (rc < 0)
+ goto err;
key[len] = 0;
if (hashtab_insert(h, key, booldatum))
goto err;
struct avtab_key key;
struct avtab_datum datum;
struct avtab_node *node_ptr;
- int len, i;
- __u32 *buf;
- __u8 found;
+ int rc;
+ u32 buf[1], i, len;
+ u8 found;
*ret_list = NULL;
len = 0;
- buf = next_entry(fp, sizeof(__u32));
- if (!buf)
+ rc = next_entry(buf, fp, sizeof buf);
+ if (rc < 0)
return -1;
len = le32_to_cpu(buf[0]);
static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
{
- __u32 *buf;
- int len, i;
+ u32 buf[2], len, i;
+ int rc;
struct cond_expr *expr = NULL, *last = NULL;
- buf = next_entry(fp, sizeof(__u32));
- if (!buf)
+ rc = next_entry(buf, fp, sizeof(u32));
+ if (rc < 0)
return -1;
node->cur_state = le32_to_cpu(buf[0]);
len = 0;
- buf = next_entry(fp, sizeof(__u32));
- if (!buf)
+ rc = next_entry(buf, fp, sizeof(u32));
+ if (rc < 0)
return -1;
/* expr */
len = le32_to_cpu(buf[0]);
for (i = 0; i < len; i++ ) {
- buf = next_entry(fp, sizeof(__u32) * 2);
- if (!buf)
+ rc = next_entry(buf, fp, sizeof(u32) * 2);
+ if (rc < 0)
goto err;
expr = kmalloc(sizeof(struct cond_expr), GFP_KERNEL);
expr->expr_type = le32_to_cpu(buf[0]);
expr->bool = le32_to_cpu(buf[1]);
- if (!expr_isvalid(p, expr))
+ if (!expr_isvalid(p, expr)) {
+ kfree(expr);
goto err;
+ }
if (i == 0) {
node->expr = expr;
int cond_read_list(struct policydb *p, void *fp)
{
struct cond_node *node, *last = NULL;
- __u32 *buf;
- int i, len;
+ u32 buf[1], i, len;
+ int rc;
- buf = next_entry(fp, sizeof(__u32));
- if (!buf)
+ rc = next_entry(buf, fp, sizeof buf);
+ if (rc < 0)
return -1;
len = le32_to_cpu(buf[0]);