[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171017191044.priqeeymjrewo5hn@pali>
Date: Tue, 17 Oct 2017 21:10:44 +0200
From: Pali Rohár <pali.rohar@...il.com>
To: Mario Limonciello <mario.limonciello@...l.com>
Cc: dvhart@...radead.org, Andy Shevchenko <andy.shevchenko@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
platform-driver-x86@...r.kernel.org,
Andy Lutomirski <luto@...nel.org>, quasisec@...gle.com,
rjw@...ysocki.net, mjg59@...gle.com, hch@....de,
Greg KH <greg@...ah.com>, Alan Cox <gnomes@...rguk.ukuu.org.uk>
Subject: Re: [PATCH v9 10/17] platform/x86: dell-smbios-wmi: Add new WMI
dispatcher driver
On Tuesday 17 October 2017 13:21:54 Mario Limonciello wrote:
> +static LIST_HEAD(wmi_list);
> +
> +static inline struct wmi_smbios_priv *get_first_smbios_priv(void)
> +{
> + return list_first_entry_or_null(&wmi_list,
> + struct wmi_smbios_priv,
> + list);
> +}
...
> +int dell_smbios_wmi_call(struct calling_interface_buffer *buffer)
> +{
> + struct wmi_smbios_priv *priv;
> + size_t difference;
> + size_t size;
> + int ret;
> +
> + priv = get_first_smbios_priv();
Mutex needs to be acquired before calling this function. Otherwise there
is a race condition between removing element from the list returned by
this call and later usage of structure priv.
> + if (!priv)
> + return -ENODEV;
> +
> + size = sizeof(struct calling_interface_buffer);
> + difference = priv->req_buf_size - sizeof(u64) - size;
> +
> + mutex_lock(&call_mutex);
> + memset(&priv->buf->ext, 0, difference);
> + memcpy(&priv->buf->std, buffer, size);
> + ret = run_smbios_call(priv->wdev);
> + memcpy(buffer, &priv->buf->std, size);
> + mutex_unlock(&call_mutex);
> +
> + return ret;
> +}
--
Pali Rohár
pali.rohar@...il.com
Powered by blists - more mailing lists