Skip to content

Commit

Permalink
apparmor: Remove unused variable 'sock' in __file_sock_perm()
Browse files Browse the repository at this point in the history
When CONFIG_SECURITY_APPARMOR_DEBUG_ASSERTS is disabled, there is a
warning that sock is unused:

  security/apparmor/file.c: In function '__file_sock_perm':
  security/apparmor/file.c:544:24: warning: unused variable 'sock' [-Wunused-variable]
    544 |         struct socket *sock = (struct socket *) file->private_data;
        |                        ^~~~

sock was moved into aa_sock_file_perm(), where the same check is
present, so remove sock and the assertion from __file_sock_perm() to fix
the warning.

Fixes: c05e705 ("apparmor: add fine grained af_unix mediation")
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Nathan Chancellor <[email protected]>
Signed-off-by: John Johansen <[email protected]>
  • Loading branch information
nathanchance authored and John Johansen committed Feb 10, 2025
1 parent 67e370a commit 3e45553
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions security/apparmor/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,8 @@ static int __file_sock_perm(const char *op, const struct cred *subj_cred,
struct aa_label *flabel, struct file *file,
u32 request, u32 denied)
{
struct socket *sock = (struct socket *) file->private_data;
int error;

AA_BUG(!sock);

/* revalidation due to label out of date. No revocation at this time */
if (!denied && aa_label_is_subset(flabel, label))
return 0;
Expand Down

0 comments on commit 3e45553

Please sign in to comment.