aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/pci/asihpi/hpioctl.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index 9683f84ecdc8..a32502e796de 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -177,16 +177,21 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
177 } else { 177 } else {
178 u16 __user *ptr = NULL; 178 u16 __user *ptr = NULL;
179 u32 size = 0; 179 u32 size = 0;
180 180 u32 adapter_present;
181 /* -1=no data 0=read from user mem, 1=write to user mem */ 181 /* -1=no data 0=read from user mem, 1=write to user mem */
182 int wrflag = -1; 182 int wrflag = -1;
183 u32 adapter = hm->h.adapter_index; 183 struct hpi_adapter *pa;
184 struct hpi_adapter *pa = &adapters[adapter]; 184
185 if (hm->h.adapter_index < HPI_MAX_ADAPTERS) {
186 pa = &adapters[hm->h.adapter_index];
187 adapter_present = pa->type;
188 } else {
189 adapter_present = 0;
190 }
185 191
186 if ((adapter >= HPI_MAX_ADAPTERS) || (!pa->type)) { 192 if (!adapter_present) {
187 hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER, 193 hpi_init_response(&hr->r0, hm->h.object,
188 HPI_ADAPTER_OPEN, 194 hm->h.function, HPI_ERROR_BAD_ADAPTER_NUMBER);
189 HPI_ERROR_BAD_ADAPTER_NUMBER);
190 195
191 uncopied_bytes = 196 uncopied_bytes =
192 copy_to_user(puhr, hr, sizeof(hr->h)); 197 copy_to_user(puhr, hr, sizeof(hr->h));