Skip to content

Commit

Permalink
apparmor: fix aa_label_asxprint return check
Browse files Browse the repository at this point in the history
Clang static analysis reports this issue
label.c:1802:3: warning: 2nd function call argument
  is an uninitialized value
  pr_info("%s", str);
  ^~~~~~~~~~~~~~~~~~

str is set from a successful call to aa_label_asxprint(&str, ...)
On failure a negative value is returned, not a -1.  So change
the check.

Fixes: f1bd904 ("apparmor: add the base fns() for domain labels")
Signed-off-by: Tom Rix <[email protected]>
Signed-off-by: John Johansen <[email protected]>
  • Loading branch information
Tom Rix authored and John Johansen committed Jul 9, 2022
1 parent 564423b commit 3e2a3a0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions security/apparmor/label.c
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,7 @@ void aa_label_xaudit(struct audit_buffer *ab, struct aa_ns *ns,
if (!use_label_hname(ns, label, flags) ||
display_mode(ns, label, flags)) {
len = aa_label_asxprint(&name, ns, label, flags, gfp);
if (len == -1) {
if (len < 0) {
AA_DEBUG("label print error");
return;
}
Expand Down Expand Up @@ -1772,7 +1772,7 @@ void aa_label_seq_xprint(struct seq_file *f, struct aa_ns *ns,
int len;

len = aa_label_asxprint(&str, ns, label, flags, gfp);
if (len == -1) {
if (len < 0) {
AA_DEBUG("label print error");
return;
}
Expand All @@ -1795,7 +1795,7 @@ void aa_label_xprintk(struct aa_ns *ns, struct aa_label *label, int flags,
int len;

len = aa_label_asxprint(&str, ns, label, flags, gfp);
if (len == -1) {
if (len < 0) {
AA_DEBUG("label print error");
return;
}
Expand Down

0 comments on commit 3e2a3a0

Please sign in to comment.