RDMA/mlx5: no need to kfree NULL pointer
authorLi Zhijian <lizhijian@fujitsu.com>
Sat, 3 Dec 2022 03:37:14 +0000 (11:37 +0800)
committerLeon Romanovsky <leon@kernel.org>
Sun, 4 Dec 2022 13:34:52 +0000 (15:34 +0200)
Goto label 'free' where it will kfree the 'in' is not needed though
it's safe to kfree NULL. Return err code directly to simplify the code.

1973 free:
1974         kfree(in);
1975         return err;

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Link: https://lore.kernel.org/r/20221203033714.25870-1-lizhijian@fujitsu.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/mlx5/mr.c

index 410cc5f..053fe94 100644 (file)
@@ -1929,10 +1929,8 @@ int mlx5_ib_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata)
        ndescs = req.num_klms ? roundup(req.num_klms, 4) : roundup(1, 4);
 
        in = kzalloc(inlen, GFP_KERNEL);
-       if (!in) {
-               err = -ENOMEM;
-               goto free;
-       }
+       if (!in)
+               return -ENOMEM;
 
        mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);