Skip to contentSkip to conversation

apparmor: Fix the return value in split_token_from_name() kernel-doc

PATCH In review Karl Mehltretter 2 participants 2 messages Sep 12 – Oct 27

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 apparmor: Fix the return value in split_token_from_name() kernel-doc

split_token_from_name() returns ERR_PTR(-EINVAL) for malformed input, but its kernel-doc describes NULL as the failure result. NULL is instead a successful result when the name following the token is empty.

Document all three results: the name, NULL for an empty name, and an error pointer for malformed input.

Fixes 63e2b423771a ("AppArmor: userspace interfaces")
Assisted-by LLM
---
 security/apparmor/procattr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
security/apparmor/procattr.c +2 -1
index c07b6e8fd9c93c73ea82361af83337774e6d1bdf..cfc45db43aa0c7418604fbba0e4c30a90f0f6cbd 100644
@@ -74,7 +74,8 @@ int aa_getprocattr(struct aa_label *label, char **string, bool newline)
  * @args: string to parse  (NOT NULL)
  * @token: stores returned parsed token value  (NOT NULL)
  *
- * Returns: start position of name after token else NULL on failure
+ * Returns: the name following the token, %NULL if the name is empty, or
+ * ERR_PTR(-EINVAL) if the input is malformed.
  */
 static char *split_token_from_name(const char *op, char *args, u64 *token)
 {
Signature · 1 line
2.39.5 (Apple Git-154)
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Karl Mehltretter

split_token_from_name() returns ERR_PTR(-EINVAL) for malformed input, but its kernel-doc describes NULL as the failure result. NULL is instead a successful result when the name following the token is empty.

Document all three results: the name, NULL for an empty name, and an error pointer for malformed input.

Fixes 63e2b423771a ("AppArmor: userspace interfaces")
Assisted-by LLM

I have pulled this into the apparmor tree

Quoted 18 lines
---
  security/apparmor/procattr.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
security/apparmor/procattr.c +2 -1
index c07b6e8fd9c93c73ea82361af83337774e6d1bdf..cfc45db43aa0c7418604fbba0e4c30a90f0f6cbd 100644
@@ -74,7 +74,8 @@ int aa_getprocattr(struct aa_label *label, char **string, bool newline)
   * @args: string to parse  (NOT NULL)
   * @token: stores returned parsed token value  (NOT NULL)
   *
- * Returns: start position of name after token else NULL on failure
+ * Returns: the name following the token, %NULL if the name is empty, or
+ * ERR_PTR(-EINVAL) if the input is malformed.
   */
  static char *split_token_from_name(const char *op, char *args, u64 *token)
  {