X86 platform drivers
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mario Limonciello <mario.limonciello@amd.com>,
	Mark Gross <mgross@linux.intel.com>,
	"open list:X86 PLATFORM DRIVERS" 
	<platform-driver-x86@vger.kernel.org>,
	markpearson@lenovo.com
Subject: Re: [PATCH v2 1/2] platform/x86: think-lmi: Fix issues with duplicate attributes
Date: Mon, 28 Jun 2021 11:30:00 +0200	[thread overview]
Message-ID: <21e896f7-69d8-e6fe-cc4e-55d3ecd44be1@redhat.com> (raw)
In-Reply-To: <20210622200755.12379-2-mario.limonciello@amd.com>

Hi,

On 6/22/21 10:07 PM, Mario Limonciello wrote:
> On an AMD based Lenovo T14, I find that the module doesn't work at
> all, and instead has a traceback with messages like:
> 
> ```
> sysfs: cannot create duplicate filename '/devices/virtual/firmware-attributes/thinklmi/attributes/Reserved'
> ```
> 
> Duplicate and reserved values showing up appear to be a firmware bug,
> but they shouldn't make the driver explode.  So catch them and skip
> them.
> 
> Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Thank you.

> ---
>  drivers/platform/x86/think-lmi.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> V1->V2 changes:
>  * Don't show reserved objects either
>  * Clear the object so it doesn't explode on module unload
> 
> diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c
> index d2644230b91f..4d8b5c185f8e 100644
> --- a/drivers/platform/x86/think-lmi.c
> +++ b/drivers/platform/x86/think-lmi.c
> @@ -691,6 +691,16 @@ static int tlmi_sysfs_init(void)
>  		if (!tlmi_priv.setting[i])
>  			continue;
>  
> +		/* check for duplicate or reserved values */
> +		if (kset_find_obj(tlmi_priv.attribute_kset, tlmi_priv.setting[i]->display_name) ||
> +		    !strcmp(tlmi_priv.setting[i]->display_name, "Reserved")) {
> +			pr_debug("duplicate or reserved attribute name found - %s\n",
> +				tlmi_priv.setting[i]->display_name);
> +			kfree(tlmi_priv.setting[i]->possible_values);

You are missing a:

			kfree(tlmi_priv.setting[i]);

here, this is done through the kobj_put in tlmi_release_attr(), but since we will
now never register the kobj we should just free this directly to avoid a memleak.

Since I want to include this important fix in my first pull-req for 5.14 I've fixed
this up locally and merged this into my review-hans branch, so there is no need to
send out a new version.

I've a non AMD ThinkPad (X1C8) which does have a single "Reserved" entry, so I'll
make sure to test the modified patch myself before sending out the 5.14 pdx86
pull-req.

Regards,

Hans




> +			tlmi_priv.setting[i] = NULL;
> +			continue;
> +		}
> +
>  		/* Build attribute */
>  		tlmi_priv.setting[i]->kobj.kset = tlmi_priv.attribute_kset;
>  		ret = kobject_init_and_add(&tlmi_priv.setting[i]->kobj, &tlmi_attr_setting_ktype,
> 


  reply	other threads:[~2021-06-28  9:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 20:07 [PATCH v2 0/2] Think-LMI improvements Mario Limonciello
2021-06-22 20:07 ` [PATCH v2 1/2] platform/x86: think-lmi: Fix issues with duplicate attributes Mario Limonciello
2021-06-28  9:30   ` Hans de Goede [this message]
2021-06-28 14:49     ` Limonciello, Mario
2021-06-22 20:07 ` [PATCH v2 2/2] platform/x86: think-lmi: Split current_value to reflect only the value Mario Limonciello
2021-06-28  9:34   ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21e896f7-69d8-e6fe-cc4e-55d3ecd44be1@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=mario.limonciello@amd.com \
    --cc=markpearson@lenovo.com \
    --cc=mgross@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox