summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2026-10-29 16:53:12 -0700
committerJohn Johansen <john.johansen@canonical.com>2026-10-29 17:02:50 -0700
commited35bbe7d06e6505401eff3f3c7a36bd1f167a17 (patch)
tree7cec0908c18c0cab79ee160f5013aeebef60535f /security
parentce94927fa4173fcc1eca27bdc65a140064c8f1e6 (diff)
apparmor: fix uninitialized variable warning in aa_inherit_files
Fix the following warning All warnings (new ones prefixed by >>): >> security/apparmor/file.c:737:53: warning: variable 'file' is uninitialized when used here [-Wuninitialized] 737 | int error = aa_file_perm(OP_INHERIT, cred, label, file, | ^~~~ security/apparmor/file.c:724:36: note: initialize the variable 'file' to silence this warning 724 | struct file *devnull = NULL, *file; | ^ | = NULL 1 warning generated. vim +/file +737 security/apparmor/file.c 719 720 /* based on selinux's flush_unauthorized_files */ 721 void aa_inherit_files(const struct cred *cred, struct files_struct *files) 722 { 723 struct aa_label *label = aa_get_newest_cred_label(cred); 724 struct file *devnull = NULL, *file; 725 bool devnull_tried = false; 726 unsigned int n = 0; 727 728 revalidate_tty(cred, label); 729 730 /* 731 * Revalidate access to inherited open files. Each file is 732 * revalidated holding only a reference to it, with no locks 733 * held, as revalidation may sleep (e.g. unix socket mediation 734 * dropping path refs, or allocating path buffers). 735 */ 736 while ((n = iterate_fd(files, n, get_next_file, &file)) != 0) { > 737 int error = aa_file_perm(OP_INHERIT, cred, label, file, Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202610292346.ehqNujiE-lkp@intel.com/ Fixes: a913281f60015 ("apparmor: don't revalidate inherited files under files->file_lock") Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security')
-rw-r--r--security/apparmor/file.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/security/apparmor/file.c b/security/apparmor/file.c
index b52781e05a5a..baca370ddfc0 100644
--- a/security/apparmor/file.c
+++ b/security/apparmor/file.c
@@ -721,7 +721,7 @@ static int get_next_file(const void *p, struct file *file, unsigned int fd)
void aa_inherit_files(const struct cred *cred, struct files_struct *files)
{
struct aa_label *label = aa_get_newest_cred_label(cred);
- struct file *devnull = NULL, *file;
+ struct file *devnull = NULL, *file = NULL;
bool devnull_tried = false;
unsigned int n = 0;