* [PATCH] ALSA: asihpi - bug fix pa use before init.
@ 2011-07-27 8:03 linux
2011-07-27 8:09 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: linux @ 2011-07-27 8:03 UTC (permalink / raw)
To: patch; +Cc: tiwai, Eliot Blennerhassett, alsa-devel
From: Eliot Blennerhassett <eblennerhassett@audioscience.com>
Fixes bug introduced by 1c073b67.
Also declare pa local to block in which it is used.
Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>
---
sound/pci/asihpi/hpioctl.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index 65fcf47..e0cff0c 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -107,7 +107,6 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
union hpi_response_buffer_v1 *hr;
u16 res_max_size;
u32 uncopied_bytes;
- struct hpi_adapter *pa = NULL;
int err = 0;
if (cmd != HPI_IOCTL_LINUX)
@@ -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 */
int wrflag = -1;
u32 adapter = hm->h.adapter_index;
+ struct hpi_adapter *pa = &adapters[adapter];
if ((adapter > HPI_MAX_ADAPTERS) || (!pa->type)) {
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)
goto out;
}
- pa = &adapters[adapter];
-
- if (mutex_lock_interruptible(&adapters[adapter].mutex)) {
+ if (mutex_lock_interruptible(&pa->mutex)) {
err = -EINTR;
goto out;
}
@@ -235,8 +233,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
"stream buffer size %d\n",
size);
- mutex_unlock(&adapters
- [adapter].mutex);
+ mutex_unlock(&pa->mutex);
err = -EINVAL;
goto out;
}
@@ -277,7 +274,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
uncopied_bytes, size);
}
- mutex_unlock(&adapters[adapter].mutex);
+ mutex_unlock(&pa->mutex);
}
/* on return response size must be set */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ALSA: asihpi - bug fix pa use before init.
2011-07-27 8:03 [PATCH] ALSA: asihpi - bug fix pa use before init linux
@ 2011-07-27 8:09 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2011-07-27 8:09 UTC (permalink / raw)
To: linux; +Cc: Eliot Blennerhassett, alsa-devel
At Wed, 27 Jul 2011 20:03:51 +1200,
linux@audioscience.com wrote:
>
> From: Eliot Blennerhassett <eblennerhassett@audioscience.com>
>
> Fixes bug introduced by 1c073b67.
> Also declare pa local to block in which it is used.
>
> Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>
Applied now. Thanks.
Takashi
> ---
> sound/pci/asihpi/hpioctl.c | 11 ++++-------
> 1 files changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
> index 65fcf47..e0cff0c 100644
> --- a/sound/pci/asihpi/hpioctl.c
> +++ b/sound/pci/asihpi/hpioctl.c
> @@ -107,7 +107,6 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> union hpi_response_buffer_v1 *hr;
> u16 res_max_size;
> u32 uncopied_bytes;
> - struct hpi_adapter *pa = NULL;
> int err = 0;
>
> if (cmd != HPI_IOCTL_LINUX)
> @@ -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 */
> int wrflag = -1;
> u32 adapter = hm->h.adapter_index;
> + struct hpi_adapter *pa = &adapters[adapter];
>
> if ((adapter > HPI_MAX_ADAPTERS) || (!pa->type)) {
> 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)
> goto out;
> }
>
> - pa = &adapters[adapter];
> -
> - if (mutex_lock_interruptible(&adapters[adapter].mutex)) {
> + if (mutex_lock_interruptible(&pa->mutex)) {
> err = -EINTR;
> goto out;
> }
> @@ -235,8 +233,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> "stream buffer size %d\n",
> size);
>
> - mutex_unlock(&adapters
> - [adapter].mutex);
> + mutex_unlock(&pa->mutex);
> err = -EINVAL;
> goto out;
> }
> @@ -277,7 +274,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> uncopied_bytes, size);
> }
>
> - mutex_unlock(&adapters[adapter].mutex);
> + mutex_unlock(&pa->mutex);
> }
>
> /* on return response size must be set */
> --
> 1.7.0.4
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-27 8:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-27 8:03 [PATCH] ALSA: asihpi - bug fix pa use before init linux
2011-07-27 8:09 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.