vfio_ap_dbf_info_init() registers a debug area via debug_register(). However, vfio_ap_init() does not unregister it if any subsequent initialization step fails, leaving the debug area registered. Fix this by calling debug_unregister() after unwinding the resources acquired during initialization. Fixes: a084c44eaa6a ("s390-vfio-ap: introduces s390 kernel debug feature for vfio_ap device driver") Signed-off-by: Haoxiang Li --- drivers/s390/crypto/vfio_ap_drv.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c index 8e69ed286bb9..9236c77e6a4c 100644 --- a/drivers/s390/crypto/vfio_ap_drv.c +++ b/drivers/s390/crypto/vfio_ap_drv.c @@ -173,28 +173,32 @@ static int __init vfio_ap_init(void) return ret; /* If there are no AP instructions, there is nothing to pass through. */ - if (!ap_instructions_available()) - return -ENODEV; + if (!ap_instructions_available()) { + ret = -ENODEV; + goto err_debug; + } ret = vfio_ap_matrix_dev_create(); if (ret) - return ret; + goto err_debug; ret = ap_driver_register(&vfio_ap_drv, THIS_MODULE, VFIO_AP_DRV_NAME); - if (ret) { - vfio_ap_matrix_dev_destroy(); - return ret; - } + if (ret) + goto err_matrix; ret = vfio_ap_mdev_register(); - if (ret) { - ap_driver_unregister(&vfio_ap_drv); - vfio_ap_matrix_dev_destroy(); - - return ret; - } + if (ret) + goto err_ap_driver; return 0; + +err_ap_driver: + ap_driver_unregister(&vfio_ap_drv); +err_matrix: + vfio_ap_matrix_dev_destroy(); +err_debug: + debug_unregister(vfio_ap_dbf_info); + return ret; } static void __exit vfio_ap_exit(void) -- 2.25.1