* [PATCH] RDMA/mlx5: no need to kfree NULL pointer
@ 2022-12-03 3:37 Li Zhijian
2022-12-04 13:35 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Li Zhijian @ 2022-12-03 3:37 UTC (permalink / raw)
To: leon, jgg; +Cc: linux-rdma, linux-kernel, Li Zhijian
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>
---
I stumbled across this little defect.
---
drivers/infiniband/hw/mlx5/mr.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 410cc5fd2523..053fe946e45a 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -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);
--
2.38.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] RDMA/mlx5: no need to kfree NULL pointer
2022-12-03 3:37 [PATCH] RDMA/mlx5: no need to kfree NULL pointer Li Zhijian
@ 2022-12-04 13:35 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2022-12-04 13:35 UTC (permalink / raw)
To: jgg, Li Zhijian; +Cc: linux-rdma, linux-kernel
On Sat, 3 Dec 2022 11:37:14 +0800, Li Zhijian wrote:
> 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;
>
> [...]
Applied, thanks!
[1/1] RDMA/mlx5: no need to kfree NULL pointer
https://git.kernel.org/rdma/rdma/c/6978837ce42f8b
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-04 13:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-03 3:37 [PATCH] RDMA/mlx5: no need to kfree NULL pointer Li Zhijian
2022-12-04 13:35 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®