From: Uwe Kleine-König Date: Mon, 8 May 2023 14:26:29 +0000 (+0200) Subject: net: stmmac: dwmac-qcom-ethqos: Drop an if with an always false condition X-Git-Tag: v6.6.17~4555^2~312^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c5f3ffe35cc92cce6292b5304409f3edc9281d66;p=platform%2Fkernel%2Flinux-rpi.git net: stmmac: dwmac-qcom-ethqos: Drop an if with an always false condition The remove callback is only ever called after .probe() returned successfully. After that get_stmmac_bsp_priv() always return non-NULL. Side note: The early exit would also be a bug because the return value of qcom_ethqos_remove() is ignored by the device core and the device is unbound unconditionally. So exiting early resulted in a dangerous resource leak as all devm allocated resources (some memory and the register mappings) are freed but the network device stays around. Using the network device afterwards probably oopses. Reviewed-by: Simon Horman Signed-off-by: Uwe Kleine-König Reviewed-by: Michal Kubiak Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 494c222..bf17c6c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -667,11 +667,7 @@ err_mem: static int qcom_ethqos_remove(struct platform_device *pdev) { - struct qcom_ethqos *ethqos; - - ethqos = get_stmmac_bsp_priv(&pdev->dev); - if (!ethqos) - return -ENODEV; + struct qcom_ethqos *ethqos = get_stmmac_bsp_priv(&pdev->dev); stmmac_pltfr_remove(pdev); ethqos_clks_config(ethqos, false);