Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

apparmor: Fix smatch warning in aa_remove_profiles

smatch reports
error: potential NULL dereference 'ns'.

this can not actually occur because it relies on aa_split_fqname setting
both ns_name and name as null but ns_name will actually always have a
value in this case.

so remove the unnecessary if (ns_name) conditional that is resulting
in the false positive further down.

Signed-off-by: John Johansen <john.johansen@canonical.com>

+6 -8
+6 -8
security/apparmor/policy.c
··· 1156 1156 if (fqname[0] == ':') { 1157 1157 char *ns_name; 1158 1158 name = aa_split_fqname(fqname, &ns_name); 1159 - if (ns_name) { 1160 - /* released below */ 1161 - ns = aa_find_namespace(root, ns_name); 1162 - if (!ns) { 1163 - info = "namespace does not exist"; 1164 - error = -ENOENT; 1165 - goto fail; 1166 - } 1159 + /* released below */ 1160 + ns = aa_find_namespace(root, ns_name); 1161 + if (!ns) { 1162 + info = "namespace does not exist"; 1163 + error = -ENOENT; 1164 + goto fail; 1167 1165 } 1168 1166 } else 1169 1167 /* released below */