devm_kfree check the pointer, there is no need to check before
devm_kfree call.
This change is to cleanup the code a bit.
Signed-off-by: Bernard Zhao <[email protected]>
---
drivers/net/ethernet/ti/am65-cpsw-qos.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-qos.c b/drivers/net/ethernet/ti/am65-cpsw-qos.c
index ebcc6386cc34..16b8794cb13c 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-qos.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-qos.c
@@ -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 {
--
2.33.1
Hello:
This patch was applied to netdev/net-next.git (master)
by Paolo Abeni <[email protected]>:
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.
>
> Signed-off-by: Bernard Zhao <[email protected]>
> ---
> 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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html