Merge tag 'apparmor-pr-2021-11-10' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / security / apparmor / label.c
index e68bcedca976b9340919216cfd7bdfa55deb268b..0b0265da19267a91dc19d23b898a244ccde89e8a 100644 (file)
@@ -425,8 +425,7 @@ struct aa_label *aa_label_alloc(int size, struct aa_proxy *proxy, gfp_t gfp)
        AA_BUG(size < 1);
 
        /*  + 1 for null terminator entry on vec */
-       new = kzalloc(sizeof(*new) + sizeof(struct aa_profile *) * (size + 1),
-                       gfp);
+       new = kzalloc(struct_size(new, vec, size + 1), gfp);
        AA_DEBUG("%s (%p)\n", __func__, new);
        if (!new)
                goto fail;
@@ -1454,7 +1453,7 @@ bool aa_update_label_name(struct aa_ns *ns, struct aa_label *label, gfp_t gfp)
        if (label->hname || labels_ns(label) != ns)
                return res;
 
-       if (aa_label_acntsxprint(&name, ns, label, FLAGS_NONE, gfp) == -1)
+       if (aa_label_acntsxprint(&name, ns, label, FLAGS_NONE, gfp) < 0)
                return res;
 
        ls = labels_set(label);
@@ -1704,7 +1703,7 @@ int aa_label_asxprint(char **strp, struct aa_ns *ns, struct aa_label *label,
 
 /**
  * aa_label_acntsxprint - allocate a __counted string buffer and print label
- * @strp: buffer to write to. (MAY BE NULL if @size == 0)
+ * @strp: buffer to write to.
  * @ns: namespace profile is being viewed from
  * @label: label to view (NOT NULL)
  * @flags: flags controlling what label info is printed