projects
/
platform
/
kernel
/
linux-amlogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
60bea48
)
ide: serverworks: potential overflow in svwks_set_pio_mode()
author
Dan Carpenter
<dan.carpenter@oracle.com>
Tue, 7 Jan 2020 13:06:07 +0000
(16:06 +0300)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Fri, 28 Feb 2020 14:42:36 +0000
(15:42 +0100)
[ Upstream commit
ce1f31b4c0b9551dd51874dd5364654ed4ca13ae
]
The "drive->dn" variable is a u8 controlled by root.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/ide/serverworks.c
patch
|
blob
|
history
diff --git
a/drivers/ide/serverworks.c
b/drivers/ide/serverworks.c
index
a97affc
..
0f57d45
100644
(file)
--- a/
drivers/ide/serverworks.c
+++ b/
drivers/ide/serverworks.c
@@
-114,6
+114,9
@@
static void svwks_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
struct pci_dev *dev = to_pci_dev(hwif->dev);
const u8 pio = drive->pio_mode - XFER_PIO_0;
+ if (drive->dn >= ARRAY_SIZE(drive_pci))
+ return;
+
pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]);
if (svwks_csb_check(dev)) {
@@
-140,6
+143,9
@@
static void svwks_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0;
+ if (drive->dn >= ARRAY_SIZE(drive_pci2))
+ return;
+
pci_read_config_byte(dev, (0x56|hwif->channel), &ultra_timing);
pci_read_config_byte(dev, 0x54, &ultra_enable);