Skip to content

Commit be387d7

Browse files
Yadi.huLee Jones
authored andcommitted
i2c-eg20t: fix race between i2c init and interrupt enable
commit 371a015 upstream. the eg20t driver call request_irq() function before the pch_base_address, base address of i2c controller's register, is assigned an effective value. there is one possible scenario that an interrupt which isn't inside eg20t arrives immediately after request_irq() is executed when i2c controller shares an interrupt number with others. since the interrupt handler pch_i2c_handler() has already active as shared action, it will be called and read its own register to determine if this interrupt is from itself. At that moment, since base address of i2c registers is not remapped in kernel space yet,so the INT handler will access an illegal address and then a error occurs. Signed-off-by: Yadi.hu <yadi.hu@windriver.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Change-Id: I02329025aaf4f1072c991918f7ca663d1685a0fb
1 parent 4dbf445 commit be387d7

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

drivers/i2c/busses/i2c-eg20t.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -773,13 +773,6 @@ static int pch_i2c_probe(struct pci_dev *pdev,
773773
/* Set the number of I2C channel instance */
774774
adap_info->ch_num = id->driver_data;
775775

776-
ret = request_irq(pdev->irq, pch_i2c_handler, IRQF_SHARED,
777-
KBUILD_MODNAME, adap_info);
778-
if (ret) {
779-
pch_pci_err(pdev, "request_irq FAILED\n");
780-
goto err_request_irq;
781-
}
782-
783776
for (i = 0; i < adap_info->ch_num; i++) {
784777
pch_adap = &adap_info->pch_data[i].pch_adapter;
785778
adap_info->pch_i2c_suspended = false;
@@ -796,6 +789,17 @@ static int pch_i2c_probe(struct pci_dev *pdev,
796789
adap_info->pch_data[i].pch_base_address = base_addr + 0x100 * i;
797790

798791
pch_adap->dev.parent = &pdev->dev;
792+
}
793+
794+
ret = request_irq(pdev->irq, pch_i2c_handler, IRQF_SHARED,
795+
KBUILD_MODNAME, adap_info);
796+
if (ret) {
797+
pch_pci_err(pdev, "request_irq FAILED\n");
798+
goto err_request_irq;
799+
}
800+
801+
for (i = 0; i < adap_info->ch_num; i++) {
802+
pch_adap = &adap_info->pch_data[i].pch_adapter;
799803

800804
pch_i2c_init(&adap_info->pch_data[i]);
801805

0 commit comments

Comments
 (0)