2022-05-11 14:22:46

by z

[permalink] [raw]
Subject: [PATCH] ethernet/ti: delete if NULL check befort devm_kfree

devm_kfree check the point, 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]>
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



2022-05-13 10:50:50

by Paolo Abeni

[permalink] [raw]
Subject: Re: [PATCH] ethernet/ti: delete if NULL check befort devm_kfree

On Wed, 2022-05-11 at 00:25 -0700, Bernard Zhao wrote:
> devm_kfree check the point, 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]>
> Signed-off-by: Bernard Zhao <[email protected]>

The patch looks good, but the somewhat strange From: header is
confusing pw and you probably want to drop one of the SoB above, please
re-send, thanks!

Paolo