Commit 48952c6
iommu: Handle default domain attach failure
commit 797a8b4d768c58caac58ee3e8cb36a164d1b7751 upstream.
We wouldn't normally expect ops->attach_dev() to fail, but on IOMMUs
with limited hardware resources, or generally misconfigured systems,
it is certainly possible. We report failure correctly from the external
iommu_attach_device() interface, but do not do so in iommu_group_add()
when attaching to the default domain. The result of failure there is
that the device, group and domain all get left in a broken,
part-configured state which leads to weird errors and misbehaviour down
the line when IOMMU API calls sort-of-but-don't-quite work.
Check the return value of __iommu_attach_device() on the default domain,
and refactor the error handling paths to cope with its failure and clean
up correctly in such cases.
Fixes: e39cb8a ("iommu: Make sure a device is always attached to a domain")
Reported-by: Punit Agrawal <punit.agrawal@arm.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 3de9630 commit 48952c6
1 file changed
Lines changed: 24 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
| 394 | + | |
| 395 | + | |
398 | 396 | | |
399 | 397 | | |
400 | 398 | | |
401 | 399 | | |
402 | | - | |
403 | | - | |
404 | | - | |
| 400 | + | |
| 401 | + | |
405 | 402 | | |
406 | 403 | | |
407 | 404 | | |
408 | 405 | | |
409 | 406 | | |
410 | | - | |
411 | 407 | | |
412 | 408 | | |
413 | 409 | | |
414 | 410 | | |
415 | 411 | | |
| 412 | + | |
416 | 413 | | |
417 | 414 | | |
418 | 415 | | |
419 | 416 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
| 417 | + | |
424 | 418 | | |
425 | 419 | | |
426 | 420 | | |
| |||
432 | 426 | | |
433 | 427 | | |
434 | 428 | | |
435 | | - | |
| 429 | + | |
436 | 430 | | |
| 431 | + | |
| 432 | + | |
437 | 433 | | |
438 | 434 | | |
439 | 435 | | |
| |||
444 | 440 | | |
445 | 441 | | |
446 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
447 | 458 | | |
448 | 459 | | |
449 | 460 | | |
| |||
0 commit comments