diff mbox series

IB/mlx5: Fix a NULL vs IS_ERR() check

Message ID 20200320132641.GF95012@mwanda (mailing list archive)
State Mainlined
Commit a766fa84738f52f8227eb96aed4362725a82ccf2
Delegated to: Jason Gunthorpe
Headers show
Series IB/mlx5: Fix a NULL vs IS_ERR() check | expand

Commit Message

Dan Carpenter March 20, 2020, 1:26 p.m. UTC
The kzalloc() function returns NULL, not error pointers.

Fixes: 30f2fe40c72b ("IB/mlx5: Introduce UAPIs to manage packet pacing")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/infiniband/hw/mlx5/qos.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Leon Romanovsky March 20, 2020, 2:29 p.m. UTC | #1
On Fri, Mar 20, 2020 at 04:26:41PM +0300, Dan Carpenter wrote:
> The kzalloc() function returns NULL, not error pointers.
>
> Fixes: 30f2fe40c72b ("IB/mlx5: Introduce UAPIs to manage packet pacing")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/infiniband/hw/mlx5/qos.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

Of course, thanks a lot.

Acked-by: Leon Romanovsky <leonro@mellanox.com>
Jason Gunthorpe March 24, 2020, 10:49 p.m. UTC | #2
On Fri, Mar 20, 2020 at 04:26:41PM +0300, Dan Carpenter wrote:
> The kzalloc() function returns NULL, not error pointers.
> 
> Fixes: 30f2fe40c72b ("IB/mlx5: Introduce UAPIs to manage packet pacing")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  drivers/infiniband/hw/mlx5/qos.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied to for-next, thanks

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/mlx5/qos.c b/drivers/infiniband/hw/mlx5/qos.c
index f822b06e7c9e..cac878a70edb 100644
--- a/drivers/infiniband/hw/mlx5/qos.c
+++ b/drivers/infiniband/hw/mlx5/qos.c
@@ -46,8 +46,8 @@  static int UVERBS_HANDLER(MLX5_IB_METHOD_PP_OBJ_ALLOC)(
 
 	dev = to_mdev(c->ibucontext.device);
 	pp_entry = kzalloc(sizeof(*pp_entry), GFP_KERNEL);
-	if (IS_ERR(pp_entry))
-		return PTR_ERR(pp_entry);
+	if (!pp_entry)
+		return -ENOMEM;
 
 	in_ctx = uverbs_attr_get_alloced_ptr(attrs,
 					     MLX5_IB_ATTR_PP_OBJ_ALLOC_CTX);