diff mbox series

RDMA/core: Trigger a WARN_ON if the driver causes uobjects to become leaked

Message ID 0-v1-b1e0ed400ba9+f7-warn_destroy_ufile_hw_jgg@nvidia.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series RDMA/core: Trigger a WARN_ON if the driver causes uobjects to become leaked | expand

Commit Message

Jason Gunthorpe Aug. 25, 2020, 4:35 p.m. UTC
Drivers that fail destroy can cause uverbs to leak uobjects. Drivers are
required to always eventually destroy their ubojects, so trigger a WARN_ON
to detect this driver bug.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/infiniband/core/rdma_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Leon Romanovsky Aug. 26, 2020, 6:37 a.m. UTC | #1
On Tue, Aug 25, 2020 at 01:35:38PM -0300, Jason Gunthorpe wrote:
> Drivers that fail destroy can cause uverbs to leak uobjects. Drivers are
> required to always eventually destroy their ubojects, so trigger a WARN_ON
> to detect this driver bug.
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  drivers/infiniband/core/rdma_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Gal Pressman Aug. 26, 2020, 8:10 a.m. UTC | #2
On 25/08/2020 19:35, Jason Gunthorpe wrote:
> Drivers that fail destroy can cause uverbs to leak uobjects. Drivers are
> required to always eventually destroy their ubojects, so trigger a WARN_ON
> to detect this driver bug.
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  drivers/infiniband/core/rdma_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
> index 3962da54ffbf47..d2b5417a4d5170 100644
> --- a/drivers/infiniband/core/rdma_core.c
> +++ b/drivers/infiniband/core/rdma_core.c
> @@ -895,8 +895,9 @@ void uverbs_destroy_ufile_hw(struct ib_uverbs_file *ufile,
>  		if (__uverbs_cleanup_ufile(ufile, reason)) {
>  			/*
>  			 * No entry was cleaned-up successfully during this
> -			 * iteration
> +			 * iteration. It is a driver bug to fail destruction.
>  			 */
> +			WARN_ON(!list_empty(&ufile->uobjects));
>  			break;
>  		}
>  
> 

Looks good,
Reviewed-by: Gal Pressman <galpress@amazon.com>
Jason Gunthorpe Aug. 31, 2020, 3:26 p.m. UTC | #3
On Tue, Aug 25, 2020 at 01:35:38PM -0300, Jason Gunthorpe wrote:
> Drivers that fail destroy can cause uverbs to leak uobjects. Drivers are
> required to always eventually destroy their ubojects, so trigger a WARN_ON
> to detect this driver bug.
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> Reviewed-by: Gal Pressman <galpress@amazon.com>
> ---
>  drivers/infiniband/core/rdma_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied to for-next

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
index 3962da54ffbf47..d2b5417a4d5170 100644
--- a/drivers/infiniband/core/rdma_core.c
+++ b/drivers/infiniband/core/rdma_core.c
@@ -895,8 +895,9 @@  void uverbs_destroy_ufile_hw(struct ib_uverbs_file *ufile,
 		if (__uverbs_cleanup_ufile(ufile, reason)) {
 			/*
 			 * No entry was cleaned-up successfully during this
-			 * iteration
+			 * iteration. It is a driver bug to fail destruction.
 			 */
+			WARN_ON(!list_empty(&ufile->uobjects));
 			break;
 		}