Skip to contentSkip to conversation

ethernet/ti: delete if NULL check befort devm_kfree

PATCH Applied Bernard Zhao 2 participants 2 messages May 16, 2022 – May 17, 2022

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

PATCH 1/1 ethernet/ti: delete if NULL check befort devm_kfree

devm_kfree check the pointer, there is no need to check before devm_kfree call.
This change is to cleanup the code a bit.

---
 drivers/net/ethernet/ti/am65-cpsw-qos.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/net/ethernet/ti/am65-cpsw-qos.c +4 -9
index ebcc6386cc34..16b8794cb13c 100644
@@ -164,8 +164,7 @@ static void am65_cpsw_admin_to_oper(struct net_device *ndev)
 {
 	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
 
-	if (port->qos.est_oper)
-		devm_kfree(&ndev->dev, port->qos.est_oper);
+	devm_kfree(&ndev->dev, port->qos.est_oper);
 
 	port->qos.est_oper = port->qos.est_admin;
 	port->qos.est_admin = NULL;
@@ -432,11 +431,8 @@ static void am65_cpsw_purge_est(struct net_device *ndev)
 
 	am65_cpsw_stop_est(ndev);
 
-	if (port->qos.est_admin)
-		devm_kfree(&ndev->dev, port->qos.est_admin);
-
-	if (port->qos.est_oper)
-		devm_kfree(&ndev->dev, port->qos.est_oper);
+	devm_kfree(&ndev->dev, port->qos.est_admin);
+	devm_kfree(&ndev->dev, port->qos.est_oper);
 
 	port->qos.est_oper = NULL;
 	port->qos.est_admin = NULL;
@@ -522,8 +518,7 @@ static int am65_cpsw_set_taprio(struct net_device *ndev, void *type_data)
 	ret = am65_cpsw_configure_taprio(ndev, est_new);
 	if (!ret) {
 		if (taprio->enable) {
-			if (port->qos.est_admin)
-				devm_kfree(&ndev->dev, port->qos.est_admin);
+			devm_kfree(&ndev->dev, port->qos.est_admin);
 
 			port->qos.est_admin = est_new;
 		} else {
Signature · 1 line
2.33.1
#1 lore raw
This patch was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Sun, 15 May 2022 18:52:05 -0700 you wrote:

devm_kfree check the pointer, there is no need to check before devm_kfree call.
This change is to cleanup the code a bit.

---
 drivers/net/ethernet/ti/am65-cpsw-qos.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Here is the summary with links:
- ethernet/ti: delete if NULL check befort devm_kfree

    https://git.kernel.org/netdev/net-next/c/1588f5a91b16

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html