lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <14753762-a3b5-454e-88bb-14bf851de9bb@app.fastmail.com>
Date: Tue, 23 Dec 2025 15:30:54 -0500
From: "Mark Pearson" <mpearson-lenovo@...ebb.ca>
To: "Benjamin Philip" <benjamin.philip495@...il.com>,
 "platform-driver-x86@...r.kernel.org" <platform-driver-x86@...r.kernel.org>,
 linux-kernel@...r.kernel.org
Cc: "Derek J . Clark" <derekjohn.clark@...il.com>,
 "Hans de Goede" <hansg@...nel.org>,
 Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Subject: Re: [PATCH 3/5] platform/x86: think-lmi: Clean up misc checks

On Tue, Dec 23, 2025, at 2:24 PM, Benjamin Philip wrote:
> This commit cleans up the following checks:
>
> - CHECK: braces {} should be used on all arms of this statement
> - CHECK: Please use a blank line after function/struct/union/enum
>   declarations
> - CHECK: Prefer kzalloc(sizeof(*new_pwd)...) over
>   kzalloc(sizeof(struct tlmi_pwd_setting)...)
> - CHECK: spaces preferred around that '/' (ctx:VxV)
> - CHECK: Unbalanced braces around else statement
>
> Signed-off-by: Benjamin Philip <benjamin.philip495@...il.com>
> ---
>  drivers/platform/x86/lenovo/think-lmi.c | 32 +++++++++++++------------
>  1 file changed, 17 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/platform/x86/lenovo/think-lmi.c
> b/drivers/platform/x86/lenovo/think-lmi.c
> index 1fac8986d077..1ada4d800383 100644
> --- a/drivers/platform/x86/lenovo/think-lmi.c
> +++ b/drivers/platform/x86/lenovo/think-lmi.c
> @@ -223,14 +223,16 @@ static const struct tlmi_err_codes tlmi_errs[] = {
>  	{"Set Certificate operation failed with status:Certificate too
> large.", -EFBIG},
>  };
>
> -static const char * const encoding_options[] = {
> +static const char *const encoding_options[] = {
>  	[TLMI_ENCODING_ASCII] = "ascii",
>  	[TLMI_ENCODING_SCANCODE] = "scancode",
>  };
> -static const char * const level_options[] = {
> +
> +static const char *const level_options[] = {
>  	[TLMI_LEVEL_USER] = "user",
>  	[TLMI_LEVEL_MASTER] = "master",
>  };
> +
>  static struct think_lmi tlmi_priv;
>  static DEFINE_MUTEX(tlmi_mutex);
>
> @@ -249,7 +251,7 @@ static int tlmi_errstr_to_err(const char *errstr)
>  {
>  	int i;
>
> -	for (i = 0; i < sizeof(tlmi_errs)/sizeof(struct tlmi_err_codes); i++) {
> +	for (i = 0; i < sizeof(tlmi_errs) / sizeof(struct tlmi_err_codes); i++) {
>  		if (!strcmp(tlmi_errs[i].err_str, errstr))
>  			return tlmi_errs[i].err_code;
>  	}
> @@ -570,19 +572,19 @@ static ssize_t mechanism_show(struct kobject
> *kobj, struct kobj_attribute *attr,
>  		return sysfs_emit(buf, "certificate\n");
>  	return sysfs_emit(buf, "password\n");
>  }
> +
>  static struct kobj_attribute auth_mechanism = __ATTR_RO(mechanism);
>
>  static ssize_t encoding_show(struct kobject *kobj, struct kobj_attribute *attr,
> -			 char *buf)
> +			     char *buf)
>  {
>  	struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
>
>  	return sysfs_emit(buf, "%s\n", encoding_options[setting->encoding]);
>  }
>
> -static ssize_t encoding_store(struct kobject *kobj,
> -				  struct kobj_attribute *attr,
> -				  const char *buf, size_t count)
> +static ssize_t encoding_store(struct kobject *kobj, struct
> kobj_attribute *attr,
> +			      const char *buf, size_t count)
>  {
>  	struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
>  	int i;
> @@ -632,19 +634,19 @@ static ssize_t role_show(struct kobject *kobj,
> struct kobj_attribute *attr,
>
>  	return sysfs_emit(buf, "%s\n", setting->role);
>  }
> +
>  static struct kobj_attribute auth_role = __ATTR_RO(role);
>
>  static ssize_t index_show(struct kobject *kobj, struct kobj_attribute *attr,
> -			 char *buf)
> +			  char *buf)
>  {
>  	struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
>
>  	return sysfs_emit(buf, "%d\n", setting->index);
>  }
>
> -static ssize_t index_store(struct kobject *kobj,
> -				  struct kobj_attribute *attr,
> -				  const char *buf, size_t count)
> +static ssize_t index_store(struct kobject *kobj, struct kobj_attribute *attr,
> +			   const char *buf, size_t count)
>  {
>  	struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
>  	int err, val;
> @@ -1047,9 +1049,9 @@ static ssize_t current_value_show(struct kobject
> *kobj, struct kobj_attribute *a
>
>  	/* validate and split from `item,value` -> `value` */
>  	value = strpbrk(item, ",");
> -	if (!value || value == item || !strlen(value + 1))
> +	if (!value || value == item || !strlen(value + 1)) {
>  		ret = -EINVAL;
> -	else {
> +	} else {
>  		/* On Workstations remove the Options part after the value */
>  		strreplace(value, ';', '\0');
>  		ret = sysfs_emit(buf, "%s\n", value + 1);
> @@ -1585,11 +1587,11 @@ static int tlmi_sysfs_init(void)
>
>  /* ---- Base Driver -------------------------------------------------------- */
>  static struct tlmi_pwd_setting *tlmi_create_auth(const char *pwd_type,
> -			    const char *pwd_role)
> +						 const char *pwd_role)
>  {
>  	struct tlmi_pwd_setting *new_pwd;
>
> -	new_pwd = kzalloc(sizeof(struct tlmi_pwd_setting), GFP_KERNEL);
> +	new_pwd = kzalloc(sizeof(*new_pwd), GFP_KERNEL);
>  	if (!new_pwd)
>  		return NULL;
>
> -- 
> 2.52.0

Reviewed-by: Mark Pearson <mpearson-lenovo@...ebb.ca>
Mark

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ