Commit 63c5395
spi: bcm-qspi: Fix use-after-free on unbind
bcm_qspi_remove() calls spi_unregister_master() even though
bcm_qspi_probe() calls devm_spi_register_master(). The spi_master is
therefore unregistered and freed twice on unbind.
Moreover, since commit 0392727 ("spi: bcm-qspi: Handle clock probe
deferral"), bcm_qspi_probe() leaks the spi_master allocation if the call
to devm_clk_get_optional() fails.
Fix by switching over to the new devm_spi_alloc_master() helper which
keeps the private data accessible until the driver has unbound and also
avoids the spi_master leak on probe.
While at it, fix an ordering issue in bcm_qspi_remove() wherein
spi_unregister_master() is called after uninitializing the hardware,
disabling the clock and freeing an IRQ data structure. The correct
order is to call spi_unregister_master() *before* those teardown steps
because bus accesses may still be ongoing until that function returns.
Fixes: fa236a7 ("spi: bcm-qspi: Add Broadcom MSPI driver")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: <stable@vger.kernel.org> # v4.9+: 123456789abc: spi: Introduce device-managed SPI controller allocation
Cc: <stable@vger.kernel.org> # v4.9+
Cc: Kamal Dasu <kdasu.kdev@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/5e31a9a59fd1c0d0b795b2fe219f25e5ee855f9d.1605121038.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>1 parent e13ee6c commit 63c5395
1 file changed
Lines changed: 12 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1327 | 1327 | | |
1328 | 1328 | | |
1329 | 1329 | | |
1330 | | - | |
| 1330 | + | |
1331 | 1331 | | |
1332 | 1332 | | |
1333 | 1333 | | |
| |||
1367 | 1367 | | |
1368 | 1368 | | |
1369 | 1369 | | |
1370 | | - | |
1371 | | - | |
1372 | | - | |
1373 | | - | |
| 1370 | + | |
| 1371 | + | |
1374 | 1372 | | |
1375 | | - | |
| 1373 | + | |
1376 | 1374 | | |
1377 | 1375 | | |
1378 | 1376 | | |
1379 | 1377 | | |
1380 | 1378 | | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
| 1379 | + | |
| 1380 | + | |
1385 | 1381 | | |
1386 | 1382 | | |
1387 | 1383 | | |
| |||
1392 | 1388 | | |
1393 | 1389 | | |
1394 | 1390 | | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
1398 | | - | |
| 1391 | + | |
| 1392 | + | |
1399 | 1393 | | |
1400 | 1394 | | |
1401 | 1395 | | |
1402 | 1396 | | |
1403 | | - | |
1404 | | - | |
1405 | | - | |
1406 | | - | |
| 1397 | + | |
| 1398 | + | |
1407 | 1399 | | |
1408 | 1400 | | |
1409 | 1401 | | |
| |||
1484 | 1476 | | |
1485 | 1477 | | |
1486 | 1478 | | |
1487 | | - | |
| 1479 | + | |
1488 | 1480 | | |
1489 | 1481 | | |
1490 | 1482 | | |
| |||
1497 | 1489 | | |
1498 | 1490 | | |
1499 | 1491 | | |
1500 | | - | |
1501 | | - | |
1502 | 1492 | | |
1503 | 1493 | | |
1504 | 1494 | | |
| |||
1508 | 1498 | | |
1509 | 1499 | | |
1510 | 1500 | | |
| 1501 | + | |
1511 | 1502 | | |
1512 | 1503 | | |
1513 | 1504 | | |
1514 | | - | |
1515 | 1505 | | |
1516 | 1506 | | |
1517 | 1507 | | |
| |||
0 commit comments