Thread (3 messages) 3 messages, 3 authors, 2023-09-28

Re: [PATCH v2] apparmor/file: Removing unnecessary initial values for variable pointers

From: John Johansen <john.johansen@canonical.com>
Date: 2023-09-28 17:36:32
Also in: lkml

On 9/18/23 18:56, Li kunyu wrote:
quoted hunk ↗ jump to hunk
These variable pointers are assigned during use and do not need to be
initialized for assignment.

Signed-off-by: Li kunyu <redacted>
---
  v2: Fix timestamp issues

  security/apparmor/file.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/apparmor/file.c b/security/apparmor/file.c
index 698b124e649f..12eafdf18fc0 100644
--- a/security/apparmor/file.c
+++ b/security/apparmor/file.c
@@ -264,7 +264,7 @@ int aa_path_perm(const char *op, struct aa_label *label,
  {
  	struct aa_perms perms = {};
  	struct aa_profile *profile;
-	char *buffer = NULL;
+	char *buffer;
this is okay
quoted hunk ↗ jump to hunk
  	int error;
  
  	flags |= PATH_DELEGATE_DELETED | (S_ISDIR(cond->mode) ? PATH_IS_DIR :
@@ -412,7 +412,7 @@ int aa_path_link(struct aa_label *label, struct dentry *old_dentry,
  		d_backing_inode(old_dentry)->i_uid,
  		d_backing_inode(old_dentry)->i_mode
  	};
-	char *buffer = NULL, *buffer2 = NULL;
+	char *buffer, *buffer2;
this can cause an oops if buffer2 allocation fails. There are a couple of ways I can
see to fix this, do you want to take a crack at it.

  	struct aa_profile *profile;
  	int error;
  
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help