diff mbox series

[for-next,1/2] RDMA/core: Check .create_ah is not NULL only in case it's needed

Message ID 20201115103404.48829-2-galpress@amazon.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series create_user_ah introduction fixups | expand

Commit Message

Gal Pressman Nov. 15, 2020, 10:34 a.m. UTC
Drivers now expose two callbacks for address handle creation, one for
uverbs and one for kverbs. The function pointer NULL check in
_rdma_create_ah() should only happen if !udata.

A NULL check for .create_user_ah is not needed as it is validated by the
uverbs uapi definitions.

Fixes: 676a80adba01 ("RDMA: Remove AH from uverbs_cmd_mask")
Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/core/verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Leon Romanovsky Nov. 15, 2020, 11:15 a.m. UTC | #1
On Sun, Nov 15, 2020 at 12:34:02PM +0200, Gal Pressman wrote:
> Drivers now expose two callbacks for address handle creation, one for
> uverbs and one for kverbs. The function pointer NULL check in
> _rdma_create_ah() should only happen if !udata.
>
> A NULL check for .create_user_ah is not needed as it is validated by the
> uverbs uapi definitions.
>
> Fixes: 676a80adba01 ("RDMA: Remove AH from uverbs_cmd_mask")
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> ---
>  drivers/infiniband/core/verbs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Jason Gunthorpe Nov. 16, 2020, 6:22 p.m. UTC | #2
On Sun, Nov 15, 2020 at 12:34:02PM +0200, Gal Pressman wrote:
> Drivers now expose two callbacks for address handle creation, one for
> uverbs and one for kverbs. The function pointer NULL check in
> _rdma_create_ah() should only happen if !udata.
> 
> A NULL check for .create_user_ah is not needed as it is validated by the
> uverbs uapi definitions.
> 
> Fixes: 676a80adba01 ("RDMA: Remove AH from uverbs_cmd_mask")

Why is this a fixes? It makes sense in the context of the next patch,
but it doesn't look like any driver sets ops.create_ah == NULL ?

Jason
Gal Pressman Nov. 16, 2020, 6:32 p.m. UTC | #3
On 16/11/2020 20:22, Jason Gunthorpe wrote:
> On Sun, Nov 15, 2020 at 12:34:02PM +0200, Gal Pressman wrote:
>> Drivers now expose two callbacks for address handle creation, one for
>> uverbs and one for kverbs. The function pointer NULL check in
>> _rdma_create_ah() should only happen if !udata.
>>
>> A NULL check for .create_user_ah is not needed as it is validated by the
>> uverbs uapi definitions.
>>
>> Fixes: 676a80adba01 ("RDMA: Remove AH from uverbs_cmd_mask")
> 
> Why is this a fixes? It makes sense in the context of the next patch,
> but it doesn't look like any driver sets ops.create_ah == NULL ?

I assumed that the NULL check should be changed regardless as it makes more
sense to only check the callback if it's used.
You can remove it if you prefer, I just hope the second patch won't be
accidentally picked up without this one.
diff mbox series

Patch

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index ab1e6048685e..33778f8674a1 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -516,7 +516,7 @@  static struct ib_ah *_rdma_create_ah(struct ib_pd *pd,
 
 	might_sleep_if(flags & RDMA_CREATE_AH_SLEEPABLE);
 
-	if (!device->ops.create_ah)
+	if (!udata && !device->ops.create_ah)
 		return ERR_PTR(-EOPNOTSUPP);
 
 	ah = rdma_zalloc_drv_obj_gfp(