esas2r: Fix array overrun
Check the array size *before* dereferencing it with a user provided offset. Signed-off-by: Alan Cox <alan@linux.intel.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
5a51a7abca
commit
5b2e0c1bef
|
@ -1360,14 +1360,15 @@ int esas2r_ioctl_handler(void *hostdata, int cmd, void __user *arg)
|
||||||
if (ioctl->header.channel == 0xFF) {
|
if (ioctl->header.channel == 0xFF) {
|
||||||
a = (struct esas2r_adapter *)hostdata;
|
a = (struct esas2r_adapter *)hostdata;
|
||||||
} else {
|
} else {
|
||||||
a = esas2r_adapters[ioctl->header.channel];
|
if (ioctl->header.channel >= MAX_ADAPTERS ||
|
||||||
if (ioctl->header.channel >= MAX_ADAPTERS || (a == NULL)) {
|
esas2r_adapters[ioctl->header.channel] == NULL) {
|
||||||
ioctl->header.return_code = IOCTL_BAD_CHANNEL;
|
ioctl->header.return_code = IOCTL_BAD_CHANNEL;
|
||||||
esas2r_log(ESAS2R_LOG_WARN, "bad channel value");
|
esas2r_log(ESAS2R_LOG_WARN, "bad channel value");
|
||||||
kfree(ioctl);
|
kfree(ioctl);
|
||||||
|
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
}
|
}
|
||||||
|
a = esas2r_adapters[ioctl->header.channel];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
|
Loading…
Reference in New Issue