priv->est is allocated with devm_kzalloc() on the first TAPRIO REPLACE and priv->est_lock is initialized in the same place, which ties the validity of the lock to whether TAPRIO has ever been configured. The lock is also never destroyed. Initialize priv->est_lock in __stmmac_dvr_probe() next to priv->lock and destroy it in stmmac_dvr_remove(). This keeps the lock valid for the entire lifetime of the device, independent of the TAPRIO state, and removes the lazy initialization from the TAPRIO configuration path. No functional change intended. Reviewed-by: Maxime Chevallier Signed-off-by: Lorenzo Bianconi --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 9ded31150fbe..2163e79fea9a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -8213,6 +8213,7 @@ static int __stmmac_dvr_probe(struct device *device, stmmac_napi_add(ndev); mutex_init(&priv->lock); + mutex_init(&priv->est_lock); rwlock_init(&priv->ptp_lock); stmmac_fpe_init(priv); @@ -8346,6 +8347,7 @@ void stmmac_dvr_remove(struct device *dev) destroy_workqueue(priv->wq); mutex_destroy(&priv->lock); + mutex_destroy(&priv->est_lock); bitmap_free(priv->af_xdp_zc_qps); pm_runtime_disable(dev); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index e137fb9012d4..aea235a69105 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -1028,8 +1028,6 @@ static int tc_taprio_configure(struct stmmac_priv *priv, GFP_KERNEL); if (!priv->est) return -ENOMEM; - - mutex_init(&priv->est_lock); } else { mutex_lock(&priv->est_lock); memset(priv->est, 0, sizeof(*priv->est)); -- 2.56.0