diff options
author | Eliot Blennerhassett <eblennerhassett@audioscience.com> | 2011-08-01 17:44:24 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-08-02 03:26:31 -0400 |
commit | 08f984c7f7f569b66acbbd163676b4bc7f64addc (patch) | |
tree | 333d7e308511ba0a3f47c9129a065f3603a52772 /sound/pci/asihpi | |
parent | dc889f18646325d07eb24ef634f082d60b0beebb (diff) |
ALSA: asihpi - Clarify adapter index validity check
Avoids assigning possibly invalid address to pa, even if it
is never dereferenced.
Correct error response to reflect request object/function ids.
Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/asihpi')
-rw-r--r-- | sound/pci/asihpi/hpioctl.c | 19 |
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)); |