mbox series

[0/9] interconnect: Convert to platform remove callback returning void

Message ID 20231031222851.3126434-11-u.kleine-koenig@pengutronix.de
Headers show
Series interconnect: Convert to platform remove callback returning void | expand

Message

Uwe Kleine-König Oct. 31, 2023, 10:28 p.m. UTC
Hello,

this series converts all platform drivers below drivers/interconnect to
use .remove_new(). Compared to the traditional .remove() callback
.remove_new() returns no value. This is a good thing because the driver
core doesn't (and cannot) cope for errors during remove. The only effect
of a non-zero return value in .remove() is that the driver core emits a
warning. The device is removed anyhow and an early return from .remove()
usually yields resource leaks and/or use-after-free bugs.

See commit 5c5a7680e67b ("platform: Provide a remove callback that
returns no value") for an extended explanation and the eventual goal.

All drivers converted here already returned zero unconditionally in
.remove(), so they are converted here trivially. The imx drivers could
be slightly simplified, because the remove callback only called a single
function with the same prototype as .remove_new().

Best regards
Uwe

Uwe Kleine-König (9):
  interconnect: qcom: Make qnoc_remove return void
  interconnect: imx8mm: Convert to platform remove callback returning
    void
  interconnect: imx8mn: Convert to platform remove callback returning
    void
  interconnect: imx8mp: Convert to platform remove callback returning
    void
  interconnect: imx8mq: Convert to platform remove callback returning
    void
  interconnect: qcom/msm8974: Convert to platform remove callback
    returning void
  interconnect: qcom/osm-l3: Convert to platform remove callback
    returning void
  interconnect: qcom/smd-rpm: Convert to platform remove callback
    returning void
  interconnect: exynos: Convert to platform remove callback returning
    void

 drivers/interconnect/imx/imx8mm.c     | 9 +--------
 drivers/interconnect/imx/imx8mn.c     | 9 +--------
 drivers/interconnect/imx/imx8mp.c     | 9 +--------
 drivers/interconnect/imx/imx8mq.c     | 9 +--------
 drivers/interconnect/qcom/icc-rpm.c   | 4 +---
 drivers/interconnect/qcom/icc-rpm.h   | 2 +-
 drivers/interconnect/qcom/msm8916.c   | 2 +-
 drivers/interconnect/qcom/msm8939.c   | 2 +-
 drivers/interconnect/qcom/msm8974.c   | 6 ++----
 drivers/interconnect/qcom/msm8996.c   | 2 +-
 drivers/interconnect/qcom/osm-l3.c    | 6 ++----
 drivers/interconnect/qcom/qcm2290.c   | 2 +-
 drivers/interconnect/qcom/qcs404.c    | 2 +-
 drivers/interconnect/qcom/sdm660.c    | 2 +-
 drivers/interconnect/qcom/smd-rpm.c   | 6 ++----
 drivers/interconnect/samsung/exynos.c | 6 ++----
 16 files changed, 20 insertions(+), 58 deletions(-)


base-commit: 9c2d379d63450ae464eeab45462e0cb573cd97d0

Comments

Krzysztof Kozlowski Nov. 1, 2023, 8:14 a.m. UTC | #1
On 31/10/2023 23:29, Uwe Kleine-König wrote:
> The .remove() callback for a platform driver returns an int which makes
> many driver authors wrongly assume it's possible to do error handling by
> returning an error code. However the value returned is ignored (apart
> from emitting a warning) and this typically results in resource leaks.
> 
> To improve here there is a quest to make the remove callback return
> void. In the first step of this quest all drivers are converted to
> .remove_new(), which already returns void. Eventually after all drivers
> are converted, .remove_new() will be renamed to .remove().
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof