lkml.org 
[lkml]   [2017]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@gmail.com

\
 
 \ /
  Last update: 2017-10-17 21:11    [W:0.171 / U:6.864 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site