qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] firmware: Convert to platform remove callback returning void
@ 2023-12-27 16:26 Uwe Kleine-König
  2023-12-27 16:26 ` [PATCH 06/11] firmware: qemu_fw_cfg: " Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
  To: Sudeep Holla, Tzung-Bi Shih, Shawn Guo, Sascha Hauer,
	Daniel Baluta, Thierry Reding, Hao Ge, Rob Herring,
	Christophe JAILLET, Matthias Brugger, AngeloGioacchino Del Regno,
	Arnd Bergmann, Gabriel Somlo, Michael S. Tsirkin,
	Florian Fainelli, Kieran Bingham, Dinh Nguyen, Marek Behún,
	Michal Simek, Greg Kroah-Hartman, Jay Buddhabhatti,
	Sai Krishna Potthuri, Linus Walleij, Nava kishore Manne,
	Rajan Vaja, Dhaval Shah, Marek Vasut
  Cc: kernel, Cristian Marussi, linux-arm-kernel, linux-kernel,
	Brian Norris, Julius Werner, chrome-platform, Fabio Estevam,
	NXP Linux Team, linux-mediatek, qemu-devel,
	Broadcom internal kernel review list, linux-rpi-kernel

Hello,

this series converts all platform drivers below drivers/firmware that
make use of .remove() to use .remove_new() instead.

See commit 5c5a7680e67b ("platform: Provide a remove callback that
returns no value") for an extended explanation and the eventual goal.
The TL;DR; is to make it harder for driver authors to leak resources
without noticing. The drivers here get it right though and so can be
converted trivially.

This is merge window material. There doesn't seem to be a maintainer for
all of drivers/firmware and I don't know how patch application works
there usually.  All patches are pairwise independent, so they can be
applied individually.

Best regards
Uwe

Uwe Kleine-König (11):
  firmware: arm_scmi: Convert to platform remove callback returning void
  firmware: arm_scpi: Convert to platform remove callback returning void
  firmware: coreboot_table: Convert to platform remove callback returning void
  firmware: imx-dsp: Convert to platform remove callback returning void
  firmware: mtk-adsp-ipc: Convert to platform remove callback returning void
  firmware: qemu_fw_cfg: Convert to platform remove callback returning void
  firmware: raspberrypi: Convert to platform remove callback returning void
  firmware: stratix10-rsu: Convert to platform remove callback returning void
  firmware: stratix10-svc: Convert to platform remove callback returning void
  firmware: turris-mox-rwtm: Convert to platform remove callback returning void
  firmware: zynqmp: Convert to platform remove callback returning void

 drivers/firmware/arm_scmi/driver.c       | 6 ++----
 drivers/firmware/arm_scpi.c              | 6 ++----
 drivers/firmware/google/coreboot_table.c | 5 ++---
 drivers/firmware/imx/imx-dsp.c           | 6 ++----
 drivers/firmware/mtk-adsp-ipc.c          | 6 ++----
 drivers/firmware/qemu_fw_cfg.c           | 5 ++---
 drivers/firmware/raspberrypi.c           | 6 ++----
 drivers/firmware/stratix10-rsu.c         | 5 ++---
 drivers/firmware/stratix10-svc.c         | 6 ++----
 drivers/firmware/turris-mox-rwtm.c       | 6 ++----
 drivers/firmware/xilinx/zynqmp.c         | 6 ++----
 11 files changed, 22 insertions(+), 41 deletions(-)

base-commit: 39676dfe52331dba909c617f213fdb21015c8d10
-- 
2.43.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 06/11] firmware: qemu_fw_cfg: Convert to platform remove callback returning void
  2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-12-27 16:26 ` Uwe Kleine-König
  2023-12-27 17:07   ` Philippe Mathieu-Daudé
  2023-12-27 20:46   ` Michael S. Tsirkin
  0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2023-12-27 16:26 UTC (permalink / raw)
  To: Gabriel Somlo, Michael S. Tsirkin; +Cc: kernel, qemu-devel, linux-kernel

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>
---
 drivers/firmware/qemu_fw_cfg.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index 1448f61173b3..03da9a4354f8 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -731,7 +731,7 @@ static int fw_cfg_sysfs_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int fw_cfg_sysfs_remove(struct platform_device *pdev)
+static void fw_cfg_sysfs_remove(struct platform_device *pdev)
 {
 	pr_debug("fw_cfg: unloading.\n");
 	fw_cfg_sysfs_cache_cleanup();
@@ -739,7 +739,6 @@ static int fw_cfg_sysfs_remove(struct platform_device *pdev)
 	fw_cfg_io_cleanup();
 	fw_cfg_kset_unregister_recursive(fw_cfg_fname_kset);
 	fw_cfg_kobj_cleanup(fw_cfg_sel_ko);
-	return 0;
 }
 
 static const struct of_device_id fw_cfg_sysfs_mmio_match[] = {
@@ -758,7 +757,7 @@ MODULE_DEVICE_TABLE(acpi, fw_cfg_sysfs_acpi_match);
 
 static struct platform_driver fw_cfg_sysfs_driver = {
 	.probe = fw_cfg_sysfs_probe,
-	.remove = fw_cfg_sysfs_remove,
+	.remove_new = fw_cfg_sysfs_remove,
 	.driver = {
 		.name = "fw_cfg",
 		.of_match_table = fw_cfg_sysfs_mmio_match,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 06/11] firmware: qemu_fw_cfg: Convert to platform remove callback returning void
  2023-12-27 16:26 ` [PATCH 06/11] firmware: qemu_fw_cfg: " Uwe Kleine-König
@ 2023-12-27 17:07   ` Philippe Mathieu-Daudé
  2023-12-27 20:46   ` Michael S. Tsirkin
  1 sibling, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-27 17:07 UTC (permalink / raw)
  To: Uwe Kleine-König, Gabriel Somlo, Michael S. Tsirkin
  Cc: kernel, qemu-devel, linux-kernel

On 27/12/23 17:26, 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>
> ---
>   drivers/firmware/qemu_fw_cfg.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 06/11] firmware: qemu_fw_cfg: Convert to platform remove callback returning void
  2023-12-27 16:26 ` [PATCH 06/11] firmware: qemu_fw_cfg: " Uwe Kleine-König
  2023-12-27 17:07   ` Philippe Mathieu-Daudé
@ 2023-12-27 20:46   ` Michael S. Tsirkin
  1 sibling, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2023-12-27 20:46 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Gabriel Somlo, kernel, qemu-devel, linux-kernel

On Wed, Dec 27, 2023 at 05:26:30PM +0100, 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>

I don't mind.

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  drivers/firmware/qemu_fw_cfg.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index 1448f61173b3..03da9a4354f8 100644
> --- a/drivers/firmware/qemu_fw_cfg.c
> +++ b/drivers/firmware/qemu_fw_cfg.c
> @@ -731,7 +731,7 @@ static int fw_cfg_sysfs_probe(struct platform_device *pdev)
>  	return err;
>  }
>  
> -static int fw_cfg_sysfs_remove(struct platform_device *pdev)
> +static void fw_cfg_sysfs_remove(struct platform_device *pdev)
>  {
>  	pr_debug("fw_cfg: unloading.\n");
>  	fw_cfg_sysfs_cache_cleanup();
> @@ -739,7 +739,6 @@ static int fw_cfg_sysfs_remove(struct platform_device *pdev)
>  	fw_cfg_io_cleanup();
>  	fw_cfg_kset_unregister_recursive(fw_cfg_fname_kset);
>  	fw_cfg_kobj_cleanup(fw_cfg_sel_ko);
> -	return 0;
>  }
>  
>  static const struct of_device_id fw_cfg_sysfs_mmio_match[] = {
> @@ -758,7 +757,7 @@ MODULE_DEVICE_TABLE(acpi, fw_cfg_sysfs_acpi_match);
>  
>  static struct platform_driver fw_cfg_sysfs_driver = {
>  	.probe = fw_cfg_sysfs_probe,
> -	.remove = fw_cfg_sysfs_remove,
> +	.remove_new = fw_cfg_sysfs_remove,
>  	.driver = {
>  		.name = "fw_cfg",
>  		.of_match_table = fw_cfg_sysfs_mmio_match,
> -- 
> 2.43.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-27 20:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-27 16:26 [PATCH 00/11] firmware: Convert to platform remove callback returning void Uwe Kleine-König
2023-12-27 16:26 ` [PATCH 06/11] firmware: qemu_fw_cfg: " Uwe Kleine-König
2023-12-27 17:07   ` Philippe Mathieu-Daudé
2023-12-27 20:46   ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).