diff options
author | Vaibhav Jain <vaibhav@linux.vnet.ibm.com> | 2017-06-02 12:56:48 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-06-06 05:09:27 -0400 |
commit | b3aa20ba2ba8072b73bd799605b8c98927b7056c (patch) | |
tree | 6ddde853e65ffba8135727a1288f157f23e6c9e5 /drivers/misc/cxl/native.c | |
parent | 7f22ced4377628074e2ac25f41a88f98eb3b03f1 (diff) |
cxl: Avoid double free_irq() for psl,slice interrupts
During an eeh call to cxl_remove can result in double free_irq of
psl,slice interrupts. This can happen if perst_reloads_same_image == 1
and call to cxl_configure_adapter() fails during slot_reset
callback. In such a case we see a kernel oops with following back-trace:
Oops: Kernel access of bad area, sig: 11 [#1]
Call Trace:
free_irq+0x88/0xd0 (unreliable)
cxl_unmap_irq+0x20/0x40 [cxl]
cxl_native_release_psl_irq+0x78/0xd8 [cxl]
pci_deconfigure_afu+0xac/0x110 [cxl]
cxl_remove+0x104/0x210 [cxl]
pci_device_remove+0x6c/0x110
device_release_driver_internal+0x204/0x2e0
pci_stop_bus_device+0xa0/0xd0
pci_stop_and_remove_bus_device+0x28/0x40
pci_hp_remove_devices+0xb0/0x150
pci_hp_remove_devices+0x68/0x150
eeh_handle_normal_event+0x140/0x580
eeh_handle_event+0x174/0x360
eeh_event_handler+0x1e8/0x1f0
This patch fixes the issue of double free_irq by checking that
variables that hold the virqs (err_hwirq, serr_hwirq, psl_virq) are
not '0' before un-mapping and resetting these variables to '0' when
they are un-mapped.
Cc: stable@vger.kernel.org
Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc/cxl/native.c')
-rw-r--r-- | drivers/misc/cxl/native.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c index 871a2f09c718..8d6ea9712dbd 100644 --- a/drivers/misc/cxl/native.c +++ b/drivers/misc/cxl/native.c | |||
@@ -1302,13 +1302,16 @@ int cxl_native_register_psl_err_irq(struct cxl *adapter) | |||
1302 | 1302 | ||
1303 | void cxl_native_release_psl_err_irq(struct cxl *adapter) | 1303 | void cxl_native_release_psl_err_irq(struct cxl *adapter) |
1304 | { | 1304 | { |
1305 | if (adapter->native->err_virq != irq_find_mapping(NULL, adapter->native->err_hwirq)) | 1305 | if (adapter->native->err_virq == 0 || |
1306 | adapter->native->err_virq != | ||
1307 | irq_find_mapping(NULL, adapter->native->err_hwirq)) | ||
1306 | return; | 1308 | return; |
1307 | 1309 | ||
1308 | cxl_p1_write(adapter, CXL_PSL_ErrIVTE, 0x0000000000000000); | 1310 | cxl_p1_write(adapter, CXL_PSL_ErrIVTE, 0x0000000000000000); |
1309 | cxl_unmap_irq(adapter->native->err_virq, adapter); | 1311 | cxl_unmap_irq(adapter->native->err_virq, adapter); |
1310 | cxl_ops->release_one_irq(adapter, adapter->native->err_hwirq); | 1312 | cxl_ops->release_one_irq(adapter, adapter->native->err_hwirq); |
1311 | kfree(adapter->irq_name); | 1313 | kfree(adapter->irq_name); |
1314 | adapter->native->err_virq = 0; | ||
1312 | } | 1315 | } |
1313 | 1316 | ||
1314 | int cxl_native_register_serr_irq(struct cxl_afu *afu) | 1317 | int cxl_native_register_serr_irq(struct cxl_afu *afu) |
@@ -1346,13 +1349,15 @@ int cxl_native_register_serr_irq(struct cxl_afu *afu) | |||
1346 | 1349 | ||
1347 | void cxl_native_release_serr_irq(struct cxl_afu *afu) | 1350 | void cxl_native_release_serr_irq(struct cxl_afu *afu) |
1348 | { | 1351 | { |
1349 | if (afu->serr_virq != irq_find_mapping(NULL, afu->serr_hwirq)) | 1352 | if (afu->serr_virq == 0 || |
1353 | afu->serr_virq != irq_find_mapping(NULL, afu->serr_hwirq)) | ||
1350 | return; | 1354 | return; |
1351 | 1355 | ||
1352 | cxl_p1n_write(afu, CXL_PSL_SERR_An, 0x0000000000000000); | 1356 | cxl_p1n_write(afu, CXL_PSL_SERR_An, 0x0000000000000000); |
1353 | cxl_unmap_irq(afu->serr_virq, afu); | 1357 | cxl_unmap_irq(afu->serr_virq, afu); |
1354 | cxl_ops->release_one_irq(afu->adapter, afu->serr_hwirq); | 1358 | cxl_ops->release_one_irq(afu->adapter, afu->serr_hwirq); |
1355 | kfree(afu->err_irq_name); | 1359 | kfree(afu->err_irq_name); |
1360 | afu->serr_virq = 0; | ||
1356 | } | 1361 | } |
1357 | 1362 | ||
1358 | int cxl_native_register_psl_irq(struct cxl_afu *afu) | 1363 | int cxl_native_register_psl_irq(struct cxl_afu *afu) |
@@ -1375,12 +1380,15 @@ int cxl_native_register_psl_irq(struct cxl_afu *afu) | |||
1375 | 1380 | ||
1376 | void cxl_native_release_psl_irq(struct cxl_afu *afu) | 1381 | void cxl_native_release_psl_irq(struct cxl_afu *afu) |
1377 | { | 1382 | { |
1378 | if (afu->native->psl_virq != irq_find_mapping(NULL, afu->native->psl_hwirq)) | 1383 | if (afu->native->psl_virq == 0 || |
1384 | afu->native->psl_virq != | ||
1385 | irq_find_mapping(NULL, afu->native->psl_hwirq)) | ||
1379 | return; | 1386 | return; |
1380 | 1387 | ||
1381 | cxl_unmap_irq(afu->native->psl_virq, afu); | 1388 | cxl_unmap_irq(afu->native->psl_virq, afu); |
1382 | cxl_ops->release_one_irq(afu->adapter, afu->native->psl_hwirq); | 1389 | cxl_ops->release_one_irq(afu->adapter, afu->native->psl_hwirq); |
1383 | kfree(afu->psl_irq_name); | 1390 | kfree(afu->psl_irq_name); |
1391 | afu->native->psl_virq = 0; | ||
1384 | } | 1392 | } |
1385 | 1393 | ||
1386 | static void recover_psl_err(struct cxl_afu *afu, u64 errstat) | 1394 | static void recover_psl_err(struct cxl_afu *afu, u64 errstat) |