Linux s390 Architecture development
 help / color / mirror / Atom feed
* [PATCH] s390/vfio-ap: Unregister the debug area on init failure
@ 2026-12-03 16:12 Haoxiang Li
  2026-12-03 16:21 ` sashiko-bot
  2026-12-03 17:06 ` Anthony Krowiak
  0 siblings, 2 replies; 3+ messages in thread
From: Haoxiang Li @ 2026-12-03 16:12 UTC (permalink / raw)
  To: akrowiak, pasic, jjherne, freude, dengler, hca, gor, agordeev,
	borntraeger, svens, mjrosato
  Cc: linux-s390, kvm, Haoxiang Li

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 <haoxiang_li2024@163.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] s390/vfio-ap: Unregister the debug area on init failure
  2026-12-03 16:12 [PATCH] s390/vfio-ap: Unregister the debug area on init failure Haoxiang Li
@ 2026-12-03 16:21 ` sashiko-bot
  2026-12-03 17:06 ` Anthony Krowiak
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-03 16:21 UTC (permalink / raw)
  To: Haoxiang Li
  Cc: linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger

> 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 <haoxiang_li2024@163.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203161237.1025099-1-haoxiang_li2024@163.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] s390/vfio-ap: Unregister the debug area on init failure
  2026-12-03 16:12 [PATCH] s390/vfio-ap: Unregister the debug area on init failure Haoxiang Li
  2026-12-03 16:21 ` sashiko-bot
@ 2026-12-03 17:06 ` Anthony Krowiak
  1 sibling, 0 replies; 3+ messages in thread
From: Anthony Krowiak @ 2026-12-03 17:06 UTC (permalink / raw)
  To: Haoxiang Li, pasic, jjherne, freude, dengler, hca, gor, agordeev,
	borntraeger, svens, mjrosato
  Cc: linux-s390, kvm



On 12/3/26 11:12 AM, Haoxiang Li wrote:
> 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.

Why not just move the vfio_ap_dbf_info_init() call to the end of the
function? That would eliminate the need for the goto's

> 
> Fixes: a084c44eaa6a ("s390-vfio-ap: introduces s390 kernel debug feature for vfio_ap device driver")
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> ---
>   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)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-03 17:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 16:12 [PATCH] s390/vfio-ap: Unregister the debug area on init failure Haoxiang Li
2026-12-03 16:21 ` sashiko-bot
2026-12-03 17:06 ` Anthony Krowiak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox