Commit 767cd365 authored by Eliot Blennerhassett's avatar Eliot Blennerhassett Committed by Takashi Iwai

ALSA: asihpi - bug fix pa use before init.

Fixes bug introduced by 1c073b67.
Also declare pa local to block in which it is used.
Signed-off-by: default avatarEliot Blennerhassett <eblennerhassett@audioscience.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 45eebda7
...@@ -107,7 +107,6 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -107,7 +107,6 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
union hpi_response_buffer_v1 *hr; union hpi_response_buffer_v1 *hr;
u16 res_max_size; u16 res_max_size;
u32 uncopied_bytes; u32 uncopied_bytes;
struct hpi_adapter *pa = NULL;
int err = 0; int err = 0;
if (cmd != HPI_IOCTL_LINUX) if (cmd != HPI_IOCTL_LINUX)
...@@ -182,6 +181,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -182,6 +181,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
/* -1=no data 0=read from user mem, 1=write to user mem */ /* -1=no data 0=read from user mem, 1=write to user mem */
int wrflag = -1; int wrflag = -1;
u32 adapter = hm->h.adapter_index; u32 adapter = hm->h.adapter_index;
struct hpi_adapter *pa = &adapters[adapter];
if ((adapter > HPI_MAX_ADAPTERS) || (!pa->type)) { if ((adapter > HPI_MAX_ADAPTERS) || (!pa->type)) {
hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER, hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER,
...@@ -197,9 +197,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -197,9 +197,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
goto out; goto out;
} }
pa = &adapters[adapter]; if (mutex_lock_interruptible(&pa->mutex)) {
if (mutex_lock_interruptible(&adapters[adapter].mutex)) {
err = -EINTR; err = -EINTR;
goto out; goto out;
} }
...@@ -235,8 +233,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -235,8 +233,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
"stream buffer size %d\n", "stream buffer size %d\n",
size); size);
mutex_unlock(&adapters mutex_unlock(&pa->mutex);
[adapter].mutex);
err = -EINVAL; err = -EINVAL;
goto out; goto out;
} }
...@@ -277,7 +274,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -277,7 +274,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
uncopied_bytes, size); uncopied_bytes, size);
} }
mutex_unlock(&adapters[adapter].mutex); mutex_unlock(&pa->mutex);
} }
/* on return response size must be set */ /* on return response size must be set */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment