diff mbox series

RDMA/uverbs: fix a NULL vs IS_ERR() bug

Message ID YJ6Got+U7lz+3n9a@mwanda (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series RDMA/uverbs: fix a NULL vs IS_ERR() bug | expand

Commit Message

Dan Carpenter May 14, 2021, 2:18 p.m. UTC
The uapi_get_object() function returns error pointers, it never returns
NULL.

Fixes: 149d3845f4a5 ("RDMA/uverbs: Add a method to introspect handles in a context")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/infiniband/core/uverbs_std_types_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Leon Romanovsky May 19, 2021, 5:37 a.m. UTC | #1
On Fri, May 14, 2021 at 05:18:10PM +0300, Dan Carpenter wrote:
> The uapi_get_object() function returns error pointers, it never returns
> NULL.
> 
> Fixes: 149d3845f4a5 ("RDMA/uverbs: Add a method to introspect handles in a context")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/infiniband/core/uverbs_std_types_device.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Jason Gunthorpe May 19, 2021, 10:50 p.m. UTC | #2
On Fri, May 14, 2021 at 05:18:10PM +0300, Dan Carpenter wrote:
> The uapi_get_object() function returns error pointers, it never returns
> NULL.
> 
> Fixes: 149d3845f4a5 ("RDMA/uverbs: Add a method to introspect handles in a context")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>  drivers/infiniband/core/uverbs_std_types_device.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied to for-rc, thanks

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/core/uverbs_std_types_device.c b/drivers/infiniband/core/uverbs_std_types_device.c
index 9ec6971056fa..818704c676c0 100644
--- a/drivers/infiniband/core/uverbs_std_types_device.c
+++ b/drivers/infiniband/core/uverbs_std_types_device.c
@@ -117,8 +117,8 @@  static int UVERBS_HANDLER(UVERBS_METHOD_INFO_HANDLES)(
 		return ret;
 
 	uapi_object = uapi_get_object(attrs->ufile->device->uapi, object_id);
-	if (!uapi_object)
-		return -EINVAL;
+	if (IS_ERR(uapi_object))
+		return PTR_ERR(uapi_object);
 
 	handles = gather_objects_handle(attrs->ufile, uapi_object, attrs,
 					out_len, &total);