sis5513: fix potential use after free
PATCH 1/1 sis5513: fix potential use after free
The function sis_find_family drops lpc_bridge reference via pci_dev_put, however, after that, field lpc_bridge->revision is read. This may result in a use after free bug. The patch moves the put operation after the condition check.
Signed-off-by Pan Bian <[email protected]>
--- drivers/ide/sis5513.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ide/sis5513.c +2 -1
@@ -434,7 +434,6 @@ static int sis_find_family(struct pci_dev *dev) lpc_bridge =pci_get_slot (dev->bus,0x10 );/* Bus 0, Dev 2, Fn 0 */ pci_read_config_byte (dev,0x49 , &prefctl); -pci_dev_put (lpc_bridge);if (lpc_bridge->revision ==0x10 && (prefctl &0x80 )) { printk(KERN_INFO DRV_NAME " %s: SiS 961B MuTIOL IDE UDMA133 controller\n",
@@ -445,6 +444,8 @@ static int sis_find_family(struct pci_dev *dev) pci_name(dev)); chipset_family =ATA_100 ; } + +pci_dev_put (lpc_bridge); } }
Signature · 1 line
2.7.4
Quoted 6 lines · Pan Bian
The function
sis_find_familydropslpc_bridgereference viapci_dev_put, however, after that, fieldlpc_bridge->revisionis read. This may result in a use after free bug. The patch moves the put operation after the condition check.Signed-off-by Pan Bian <[email protected]>
Looks good,
Reviewed-by Christoph Hellwig <[email protected]>