Zijun Hu fe4bfa9b6d phy: core: Fix that API devm_phy_put() fails to release the phy
For devm_phy_put(), its comment says it needs to invoke phy_put() to
release the phy, but it will not actually invoke the function since
devres_destroy() does not call devm_phy_release(), and the missing
phy_put() call will cause:

- The phy fails to be released.
- devm_phy_put() can not fully undo what API devm_phy_get() does.
- Leak refcount of both the module and device for below typical usage:

  devm_phy_get(); // or its variant
  ...
  err = do_something();
  if (err)
      goto err_out;
  ...
  err_out:
  devm_phy_put(); // leak refcount here

  The file(s) affected by this issue are shown below since they have such
  typical usage.
  drivers/pci/controller/cadence/pcie-cadence.c
  drivers/net/ethernet/ti/am65-cpsw-nuss.c

Fix by using devres_release() instead of devres_destroy() within the API.

Fixes: ff764963479a ("drivers: phy: add generic PHY framework")
Cc: stable@vger.kernel.org
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Krzysztof Wilczyński <kw@linux.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20241213-phy_core_fix-v6-1-40ae28f5015a@quicinc.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2024-12-24 19:55:37 +05:30
..
2024-11-26 18:05:44 -08:00
2024-11-20 12:55:41 -08:00
2024-11-29 11:43:29 -08:00
2024-11-30 15:47:29 -08:00
2024-11-21 08:28:08 -08:00
2024-11-07 08:25:08 +01:00
2024-11-23 10:44:31 -08:00
2024-11-26 18:05:44 -08:00
2024-11-29 11:43:29 -08:00
2024-11-25 18:31:48 -08:00
2024-11-27 13:25:47 -08:00
2024-11-23 10:44:31 -08:00
2024-11-25 17:12:54 -08:00
2024-11-29 11:43:29 -08:00
2024-11-29 13:06:06 -08:00
2024-11-05 05:33:46 +01:00
2024-11-27 12:23:43 +01:00
2024-11-25 10:31:39 -08:00
2024-11-27 14:24:34 -08:00
2024-11-09 09:14:12 -08:00
2024-11-30 15:47:29 -08:00
2024-11-20 14:05:34 -08:00
2024-11-20 12:51:32 -08:00
2024-11-28 10:15:20 -08:00
2024-11-27 13:11:58 -08:00
2024-11-30 15:47:29 -08:00
2024-12-01 13:38:24 -08:00
2024-11-30 18:23:05 -08:00
2024-11-30 14:33:44 -08:00
2024-11-29 11:43:29 -08:00
2024-12-01 13:38:24 -08:00
2024-11-15 00:32:29 +11:00
2024-11-28 09:40:53 -08:00
2024-11-26 18:36:55 -08:00
2024-11-30 11:18:16 -08:00
2024-11-29 11:43:29 -08:00
2024-11-29 11:43:29 -08:00
2024-11-30 14:45:29 -08:00
2024-11-21 08:28:08 -08:00
2024-11-27 13:38:09 -08:00
2024-11-28 10:06:00 -08:00
2024-11-25 18:50:55 -08:00
2024-11-12 15:48:08 +01:00
2024-11-25 18:50:55 -08:00
2024-11-30 13:41:50 -08:00
2024-11-27 12:57:03 -08:00
2024-11-27 13:11:58 -08:00
2024-11-20 15:13:02 -08:00