Skip to contentSkip to conversation

RDMA/cxgb4: Delete an unnecessary check before kfree() in c4iw_rdev_open()

PATCH Applied Markus Elfring 2 participants 3 messages Jun 10, 2025 – Jun 12, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/cxgb4: Delete an unnecessary check before kfree() in c4iw_rdev_open()

From: Markus Elfring <[email protected]>
Date: Tue, 10 Jun 2025 14:14:09 +0200

It can be known that the function “kfree” performs a null pointer check for its input parameter.
It is therefore not needed to repeat such a check before its call.

Thus remove a redundant pointer check.

The source code was transformed by using the Coccinelle software.

---
 drivers/infiniband/hw/cxgb4/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/cxgb4/device.c +1 -1
index 034b85c42255..c0eb166a49b9 100644
@@ -905,7 +905,7 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
 
 	return 0;
 err_free_status_page_and_wr_log:
-	if (c4iw_wr_log && rdev->wr_log)
+	if (c4iw_wr_log)
 		kfree(rdev->wr_log);
 	free_page((unsigned long)rdev->status_page);
 destroy_ocqp_pool:
Signature · 1 line
2.49.0
#1 lore raw
Quoted 21 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 10 Jun 2025 14:14:09 +0200

It can be known that the function “kfree” performs a null pointer check for its input parameter.
It is therefore not needed to repeat such a check before its call.

Thus remove a redundant pointer check.

The source code was transformed by using the Coccinelle software.

---
 drivers/infiniband/hw/cxgb4/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/cxgb4/device.c +0 -0
index 034b85c42255..c0eb166a49b9 100644

drivers/infiniband/hw/cxgb4/device.c static int c4iw_rdev_open(struct c4iw_rdev *rdev) · line 908

Quoted 5 lines
drivers/infiniband/hw/cxgb4/device.c +1 -1
@@ -905,7 +905,7 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
 
 	return 0;
 err_free_status_page_and_wr_log:
-	if (c4iw_wr_log && rdev->wr_log)
+	if (c4iw_wr_log)

This is not needed too, fixed locally.

Quoted 7 lines
drivers/infiniband/hw/cxgb4/device.c +0 -0
 		kfree(rdev->wr_log);
 	free_page((unsigned long)rdev->status_page);
 destroy_ocqp_pool:
Signature · 1 line
2.49.0
#2 lore raw
In reply to Markus Elfring
Quoted 9 lines · Markus Elfring

It can be known that the function “kfree” performs a null pointer check for its input parameter.
It is therefore not needed to repeat such a check before its call.

Thus remove a redundant pointer check.

The source code was transformed by using the Coccinelle software.

[...]

Applied, thanks!

[1/1] RDMA/cxgb4: Delete an unnecessary check before kfree() in c4iw_rdev_open()

      https://git.kernel.org/rdma/rdma/c/fd383bf8b6954d

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>