mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-19 10:44:14 +08:00
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>
This commit is contained in:
parent
dc889f1864
commit
08f984c7f7
@ -177,16 +177,21 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||||||
} else {
|
} else {
|
||||||
u16 __user *ptr = NULL;
|
u16 __user *ptr = NULL;
|
||||||
u32 size = 0;
|
u32 size = 0;
|
||||||
|
u32 adapter_present;
|
||||||
/* -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;
|
struct hpi_adapter *pa;
|
||||||
struct hpi_adapter *pa = &adapters[adapter];
|
|
||||||
|
|
||||||
if ((adapter >= HPI_MAX_ADAPTERS) || (!pa->type)) {
|
if (hm->h.adapter_index < HPI_MAX_ADAPTERS) {
|
||||||
hpi_init_response(&hr->r0, HPI_OBJ_ADAPTER,
|
pa = &adapters[hm->h.adapter_index];
|
||||||
HPI_ADAPTER_OPEN,
|
adapter_present = pa->type;
|
||||||
HPI_ERROR_BAD_ADAPTER_NUMBER);
|
} else {
|
||||||
|
adapter_present = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!adapter_present) {
|
||||||
|
hpi_init_response(&hr->r0, hm->h.object,
|
||||||
|
hm->h.function, HPI_ERROR_BAD_ADAPTER_NUMBER);
|
||||||
|
|
||||||
uncopied_bytes =
|
uncopied_bytes =
|
||||||
copy_to_user(puhr, hr, sizeof(hr->h));
|
copy_to_user(puhr, hr, sizeof(hr->h));
|
||||||
|
Loading…
Reference in New Issue
Block a user