Skip to content

Commit d47f418

Browse files
duanzhenzhongMichael Tokarev
authored andcommitted
vfio/iommufd: Fix SIGSEV in iommufd_cdev_attach()
When iommufd_cdev_ram_block_discard_disable() fails for whatever reason, errp should be set or else SIGSEV is triggered in vfio_realize() when error_prepend() is called. By this chance, use the same error message for both legacy and iommufd backend. Fixes: 5ee3dc7 ("vfio/iommufd: Implement the iommufd backend") Signed-off-by: Zhenzhong Duan <[email protected]> Reviewed-by: Eric Auger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Cédric Le Goater <[email protected]> (cherry picked from commit 7b3d5b8) Signed-off-by: Michael Tokarev <[email protected]>
1 parent fe21d93 commit d47f418

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hw/vfio/iommufd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,8 @@ static bool iommufd_cdev_attach(const char *name, VFIODevice *vbasedev,
515515
} else {
516516
ret = iommufd_cdev_ram_block_discard_disable(true);
517517
if (ret) {
518-
error_setg(errp,
519-
"Cannot set discarding of RAM broken (%d)", ret);
518+
error_setg_errno(errp, -ret,
519+
"Cannot set discarding of RAM broken");
520520
goto err_discard_disable;
521521
}
522522
goto found_container;
@@ -544,6 +544,7 @@ static bool iommufd_cdev_attach(const char *name, VFIODevice *vbasedev,
544544

545545
ret = iommufd_cdev_ram_block_discard_disable(true);
546546
if (ret) {
547+
error_setg_errno(errp, -ret, "Cannot set discarding of RAM broken");
547548
goto err_discard_disable;
548549
}
549550

0 commit comments

Comments
 (0)