mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Limonciello, Mario" <Mario.Limonciello@dell.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Divya Bharathi <divya27392@gmail.com>,
	Darren Hart <dvhart@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Platform Driver <platform-driver-x86@vger.kernel.org>,
	"Bharathi, Divya" <Divya.Bharathi@Dell.com>,
	"Ksr, Prasanth" <Prasanth.Ksr@dell.com>
Subject: Re: [PATCH] Introduce support for Systems Management Driver over WMI for Dell Systems
Date: Mon, 14 Sep 2020 11:53:17 +0200	[thread overview]
Message-ID: <71aebcf6-ecc5-72ce-e230-8bd25a294de8@redhat.com> (raw)
In-Reply-To: <DM6PR19MB2636225813D7359A210D8DCCFA2C0@DM6PR19MB2636.namprd19.prod.outlook.com>

Hi,

On 9/3/20 4:27 PM, Limonciello, Mario wrote:

<snip>

>>>> +     /* look up if user set a password for the requests */
>>>> +     current_password = get_current_password("Admin");
>>>> +     if (!current_password)
>>>> +             return -ENODEV;
>>>
>>> Can we instead of passing "Admin" and "System" to this function
>>> just have 2 separate get_current_admin_password and
>> get_current_system_password
>>> helpers and then drop the error handling ?
> 
> The error handling for -ENODEV is actually important in case a WMI driver
> was unbound.

I see and checking for that is good, but then please make it
explicit, rather then hiding it like this. As is the code suggests
to someone reading the code that the problem is a missing password not
the driver being unbound.

As I mentioned before, since the code clearly assume that
only 1 instance of each WMI GUID is present, it should move to
storing all its data into a shared global struct. Protected
by a single shared global mutex.

And then functions exposed through sysfs attributes can do:

	mutex_lock(&dell_wmi_bios_attr_mutex);

	if (!dell_wmi_bios_attr_data.bios_attr_wdev ||
	    !dell_wmi_bios_attr_data.password_attr_wdev) {
		mutex_unlock(&call_mutex);
		return -ENODEV;
	}

And the password data can simply be directly read from
dell_wmi_bios_attr_data without needing a helper for it at all.

>>>> +
>>>> +     /* password is set */
>>>> +     if (strlen(current_password) > 0)
>>>> +             security_area_size = (sizeof(u32) * 2) +
>> strlen(current_password) +
>>>> +                                     strlen(current_password) % 2;
>>>> +     /* password not set */
>>>> +     else
>>>> +             security_area_size = sizeof(u32) * 2;
>>>
>>> Since you are using more then 1 line here please use {} around the state-
>> ments,
>>> also please put the /* password not set */ after the else:
>>>
>>>                  ...
>>>          } else { /* password not set */
>>>                  ...
>>>
>>>> +     string_area_size = (strlen(a_name) + strlen(a_value))*2;
>>>> +     buffer_size = security_area_size + string_area_size + sizeof(u16) *
>> 2;
>>>> +
>>>> +     buffer = kzalloc(buffer_size, GFP_KERNEL);
>>
>> Actually above looks like home grown kasprintf() implementation.
> 
> I don't think so, sprintf isn't used at all here.  It's a calculation to determine
> the size of the buffer to use.

Ack, this is different because it concats a UTF16 string together with some
other data into the new buf.

Regards,

Hans


      reply	other threads:[~2020-09-14  9:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-30 14:31 Divya Bharathi
2020-08-08 18:37 ` Limonciello, Mario
2020-08-10  8:27   ` Andy Shevchenko
2020-09-01  9:49 ` Hans de Goede
2020-09-01 14:17   ` Limonciello, Mario
2020-09-14  9:13     ` Hans de Goede
2020-09-14  9:13     ` Hans de Goede
2020-09-14 16:06       ` Limonciello, Mario
2020-09-17 10:11         ` Hans de Goede
2020-09-17 16:18           ` Limonciello, Mario
2020-09-21 10:02             ` Hans de Goede
2020-09-21 15:26               ` Limonciello, Mario
2020-09-22  8:57                 ` Hans de Goede
2020-09-22  9:14                   ` Hans de Goede
2020-09-22 18:02                     ` Limonciello, Mario
2020-09-22  9:02                 ` Hans de Goede
2020-09-01 10:09 ` Hans de Goede
2020-09-01 14:22   ` Limonciello, Mario
2020-09-14  8:45     ` Hans de Goede
2020-09-14  8:57       ` Hans de Goede
2020-09-01 11:41 ` Hans de Goede
2020-09-02  8:04   ` Andy Shevchenko
2020-09-03 14:27     ` Limonciello, Mario
2020-09-14  9:53       ` Hans de Goede [this message]

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=71aebcf6-ecc5-72ce-e230-8bd25a294de8@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=Divya.Bharathi@Dell.com \
    --cc=Mario.Limonciello@dell.com \
    --cc=Prasanth.Ksr@dell.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=divya27392@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --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

Powered by JetHome