linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] tpm: Convert to platform remove callback returning void
@ 2023-03-20  8:06 Uwe Kleine-König
  2023-03-20  8:06 ` [PATCH 1/3] tpm/tpm_ftpm_tee: " Uwe Kleine-König
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2023-03-20  8:06 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen; +Cc: Jason Gunthorpe, linux-integrity, kernel

Hello,

this series adapts the platform drivers below drivers/char/tpm to use the
.remove_new() callback. 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 a
resource leak.

The drivers converted here returned zero in their remove callback, to the
transformation was easy.

Best regards
Uwe

Uwe Kleine-König (3):
  tpm/tpm_ftpm_tee: Convert to platform remove callback returning void
  tpm/tpm_tis: Convert to platform remove callback returning void
  tpm/tpm_tis_synquacer: Convert to platform remove callback returning
    void

 drivers/char/tpm/tpm_ftpm_tee.c      | 6 +++---
 drivers/char/tpm/tpm_tis.c           | 6 ++----
 drivers/char/tpm/tpm_tis_synquacer.c | 6 ++----
 3 files changed, 7 insertions(+), 11 deletions(-)

base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
-- 
2.39.2


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

* [PATCH 1/3] tpm/tpm_ftpm_tee: Convert to platform remove callback returning void
  2023-03-20  8:06 [PATCH 0/3] tpm: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-03-20  8:06 ` Uwe Kleine-König
  2023-03-20  8:06 ` [PATCH 2/3] tpm/tpm_tis: " Uwe Kleine-König
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2023-03-20  8:06 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen; +Cc: Jason Gunthorpe, linux-integrity, 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 (mostly) ignored
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.

ftpm_tee_remove() returns zero unconditionally (and cannot easily
converted to return void). So ignore the return value to be able to make
ftpm_plat_tee_remove() return void.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/char/tpm/tpm_ftpm_tee.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/char/tpm/tpm_ftpm_tee.c b/drivers/char/tpm/tpm_ftpm_tee.c
index deff23bb54bf..528f35b14fb6 100644
--- a/drivers/char/tpm/tpm_ftpm_tee.c
+++ b/drivers/char/tpm/tpm_ftpm_tee.c
@@ -334,11 +334,11 @@ static int ftpm_tee_remove(struct device *dev)
 	return 0;
 }
 
-static int ftpm_plat_tee_remove(struct platform_device *pdev)
+static void ftpm_plat_tee_remove(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 
-	return ftpm_tee_remove(dev);
+	ftpm_tee_remove(dev);
 }
 
 /**
@@ -367,7 +367,7 @@ static struct platform_driver ftpm_tee_plat_driver = {
 	},
 	.shutdown = ftpm_plat_tee_shutdown,
 	.probe = ftpm_plat_tee_probe,
-	.remove = ftpm_plat_tee_remove,
+	.remove_new = ftpm_plat_tee_remove,
 };
 
 /* UUID of the fTPM TA */
-- 
2.39.2


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

* [PATCH 2/3] tpm/tpm_tis: Convert to platform remove callback returning void
  2023-03-20  8:06 [PATCH 0/3] tpm: Convert to platform remove callback returning void Uwe Kleine-König
  2023-03-20  8:06 ` [PATCH 1/3] tpm/tpm_ftpm_tee: " Uwe Kleine-König
@ 2023-03-20  8:06 ` Uwe Kleine-König
  2023-03-20  8:06 ` [PATCH 3/3] tpm/tpm_tis_synquacer: " Uwe Kleine-König
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2023-03-20  8:06 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen; +Cc: Jason Gunthorpe, linux-integrity, 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 (mostly) ignored
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.

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/char/tpm/tpm_tis.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index ed5dabd3c72d..fe2b889cd13d 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -324,14 +324,12 @@ static int tpm_tis_plat_probe(struct platform_device *pdev)
 	return tpm_tis_init(&pdev->dev, &tpm_info);
 }
 
-static int tpm_tis_plat_remove(struct platform_device *pdev)
+static void tpm_tis_plat_remove(struct platform_device *pdev)
 {
 	struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
 
 	tpm_chip_unregister(chip);
 	tpm_tis_remove(chip);
-
-	return 0;
 }
 
 #ifdef CONFIG_OF
@@ -344,7 +342,7 @@ MODULE_DEVICE_TABLE(of, tis_of_platform_match);
 
 static struct platform_driver tis_drv = {
 	.probe = tpm_tis_plat_probe,
-	.remove = tpm_tis_plat_remove,
+	.remove_new = tpm_tis_plat_remove,
 	.driver = {
 		.name		= "tpm_tis",
 		.pm		= &tpm_tis_pm,
-- 
2.39.2


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

* [PATCH 3/3] tpm/tpm_tis_synquacer: Convert to platform remove callback returning void
  2023-03-20  8:06 [PATCH 0/3] tpm: Convert to platform remove callback returning void Uwe Kleine-König
  2023-03-20  8:06 ` [PATCH 1/3] tpm/tpm_ftpm_tee: " Uwe Kleine-König
  2023-03-20  8:06 ` [PATCH 2/3] tpm/tpm_tis: " Uwe Kleine-König
@ 2023-03-20  8:06 ` Uwe Kleine-König
  2023-03-20 13:48 ` [PATCH 0/3] tpm: " Jarkko Sakkinen
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2023-03-20  8:06 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen; +Cc: Jason Gunthorpe, linux-integrity, 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 (mostly) ignored
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.

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/char/tpm/tpm_tis_synquacer.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis_synquacer.c b/drivers/char/tpm/tpm_tis_synquacer.c
index 679196c61401..49278746b0e2 100644
--- a/drivers/char/tpm/tpm_tis_synquacer.c
+++ b/drivers/char/tpm/tpm_tis_synquacer.c
@@ -127,14 +127,12 @@ static int tpm_tis_synquacer_probe(struct platform_device *pdev)
 	return tpm_tis_synquacer_init(&pdev->dev, &tpm_info);
 }
 
-static int tpm_tis_synquacer_remove(struct platform_device *pdev)
+static void tpm_tis_synquacer_remove(struct platform_device *pdev)
 {
 	struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
 
 	tpm_chip_unregister(chip);
 	tpm_tis_remove(chip);
-
-	return 0;
 }
 
 #ifdef CONFIG_OF
@@ -155,7 +153,7 @@ MODULE_DEVICE_TABLE(acpi, tpm_synquacer_acpi_tbl);
 
 static struct platform_driver tis_synquacer_drv = {
 	.probe = tpm_tis_synquacer_probe,
-	.remove = tpm_tis_synquacer_remove,
+	.remove_new = tpm_tis_synquacer_remove,
 	.driver = {
 		.name		= "tpm_tis_synquacer",
 		.pm		= &tpm_tis_synquacer_pm,
-- 
2.39.2


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

* Re: [PATCH 0/3] tpm: Convert to platform remove callback returning void
  2023-03-20  8:06 [PATCH 0/3] tpm: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2023-03-20  8:06 ` [PATCH 3/3] tpm/tpm_tis_synquacer: " Uwe Kleine-König
@ 2023-03-20 13:48 ` Jarkko Sakkinen
  2023-04-17  6:05 ` Uwe Kleine-König
  2023-04-23  5:08 ` Jarkko Sakkinen
  5 siblings, 0 replies; 10+ messages in thread
From: Jarkko Sakkinen @ 2023-03-20 13:48 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, kernel

On Mon, Mar 20, 2023 at 09:06:04AM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> this series adapts the platform drivers below drivers/char/tpm to use the
> .remove_new() callback. 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 a
> resource leak.
> 
> The drivers converted here returned zero in their remove callback, to the
> transformation was easy.
> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (3):
>   tpm/tpm_ftpm_tee: Convert to platform remove callback returning void
>   tpm/tpm_tis: Convert to platform remove callback returning void
>   tpm/tpm_tis_synquacer: Convert to platform remove callback returning
>     void
> 
>  drivers/char/tpm/tpm_ftpm_tee.c      | 6 +++---
>  drivers/char/tpm/tpm_tis.c           | 6 ++----
>  drivers/char/tpm/tpm_tis_synquacer.c | 6 ++----
>  3 files changed, 7 insertions(+), 11 deletions(-)
> 
> base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
> -- 
> 2.39.2
> 

To all:

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko

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

* Re: [PATCH 0/3] tpm: Convert to platform remove callback returning void
  2023-03-20  8:06 [PATCH 0/3] tpm: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2023-03-20 13:48 ` [PATCH 0/3] tpm: " Jarkko Sakkinen
@ 2023-04-17  6:05 ` Uwe Kleine-König
  2023-04-23  6:13   ` Jarkko Sakkinen
  2023-04-23  5:08 ` Jarkko Sakkinen
  5 siblings, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2023-04-17  6:05 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen; +Cc: Jason Gunthorpe, linux-integrity, kernel

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

Hello,

On Mon, Mar 20, 2023 at 09:06:04AM +0100, Uwe Kleine-König wrote:
> this series adapts the platform drivers below drivers/char/tpm to use the
> .remove_new() callback. 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 a
> resource leak.
> 
> The drivers converted here returned zero in their remove callback, to the
> transformation was easy.

who is responsible to pick up this patch set (or express their concerns
when not applying it)?

There is (for now) no coordination necessary, the final conversion of
platform_driver's remove callback is still far away. So applying it via
it's usual repo would be great.

Thanks
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 0/3] tpm: Convert to platform remove callback returning void
  2023-03-20  8:06 [PATCH 0/3] tpm: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (4 preceding siblings ...)
  2023-04-17  6:05 ` Uwe Kleine-König
@ 2023-04-23  5:08 ` Jarkko Sakkinen
  5 siblings, 0 replies; 10+ messages in thread
From: Jarkko Sakkinen @ 2023-04-23  5:08 UTC (permalink / raw)
  To: Uwe Kleine-König, Peter Huewe
  Cc: Jason Gunthorpe, linux-integrity, kernel

On Mon, 2023-03-20 at 09:06 +0100, Uwe Kleine-König wrote:
> Hello,
> 
> this series adapts the platform drivers below drivers/char/tpm to use the
> .remove_new() callback. 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 a
> resource leak.
> 
> The drivers converted here returned zero in their remove callback, to the
> transformation was easy.
> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (3):
>   tpm/tpm_ftpm_tee: Convert to platform remove callback returning void
>   tpm/tpm_tis: Convert to platform remove callback returning void
>   tpm/tpm_tis_synquacer: Convert to platform remove callback returning
>     void
> 
>  drivers/char/tpm/tpm_ftpm_tee.c      | 6 +++---
>  drivers/char/tpm/tpm_tis.c           | 6 ++----
>  drivers/char/tpm/tpm_tis_synquacer.c | 6 ++----
>  3 files changed, 7 insertions(+), 11 deletions(-)
> 
> base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6

I've applied these, thank you.

BR, Jarkko

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

* Re: [PATCH 0/3] tpm: Convert to platform remove callback returning void
  2023-04-17  6:05 ` Uwe Kleine-König
@ 2023-04-23  6:13   ` Jarkko Sakkinen
  2023-04-23  8:02     ` Uwe Kleine-König
  0 siblings, 1 reply; 10+ messages in thread
From: Jarkko Sakkinen @ 2023-04-23  6:13 UTC (permalink / raw)
  To: Uwe Kleine-König, Peter Huewe
  Cc: Jason Gunthorpe, linux-integrity, kernel

On Mon, 2023-04-17 at 08:05 +0200, Uwe Kleine-König wrote:
> Hello,
> 
> On Mon, Mar 20, 2023 at 09:06:04AM +0100, Uwe Kleine-König wrote:
> > this series adapts the platform drivers below drivers/char/tpm to use the
> > .remove_new() callback. 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 a
> > resource leak.
> > 
> > The drivers converted here returned zero in their remove callback, to the
> > transformation was easy.
> 
> who is responsible to pick up this patch set (or express their concerns
> when not applying it)?
> 
> There is (for now) no coordination necessary, the final conversion of
> platform_driver's remove callback is still far away. So applying it via
> it's usual repo would be great.

Please check https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git/

If you see anything abnormal, please report, and I will fix before sending
the pull request to Linus.

BR, Jarkko

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

* Re: [PATCH 0/3] tpm: Convert to platform remove callback returning void
  2023-04-23  6:13   ` Jarkko Sakkinen
@ 2023-04-23  8:02     ` Uwe Kleine-König
  2023-04-23 15:44       ` Jarkko Sakkinen
  0 siblings, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2023-04-23  8:02 UTC (permalink / raw)
  To: Jarkko Sakkinen; +Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, kernel

[-- Attachment #1: Type: text/plain, Size: 1573 bytes --]

Hello Jarkko,

On Sun, Apr 23, 2023 at 09:13:57AM +0300, Jarkko Sakkinen wrote:
> On Mon, 2023-04-17 at 08:05 +0200, Uwe Kleine-König wrote:
> > Hello,
> > 
> > On Mon, Mar 20, 2023 at 09:06:04AM +0100, Uwe Kleine-König wrote:
> > > this series adapts the platform drivers below drivers/char/tpm to use the
> > > .remove_new() callback. 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 a
> > > resource leak.
> > > 
> > > The drivers converted here returned zero in their remove callback, to the
> > > transformation was easy.
> > 
> > who is responsible to pick up this patch set (or express their concerns
> > when not applying it)?
> > 
> > There is (for now) no coordination necessary, the final conversion of
> > platform_driver's remove callback is still far away. So applying it via
> > it's usual repo would be great.
> 
> Please check https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git/

Looking at the topmost three commits in your next branch (i.e.
0760dc1b2f58fe741bddb6a0030720dfd6ac4689) it looks fine to me.

Thanks
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 0/3] tpm: Convert to platform remove callback returning void
  2023-04-23  8:02     ` Uwe Kleine-König
@ 2023-04-23 15:44       ` Jarkko Sakkinen
  0 siblings, 0 replies; 10+ messages in thread
From: Jarkko Sakkinen @ 2023-04-23 15:44 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, kernel

On Sun Apr 23, 2023 at 11:02 AM EEST, Uwe Kleine-König wrote:
> Hello Jarkko,
>
> On Sun, Apr 23, 2023 at 09:13:57AM +0300, Jarkko Sakkinen wrote:
> > On Mon, 2023-04-17 at 08:05 +0200, Uwe Kleine-König wrote:
> > > Hello,
> > > 
> > > On Mon, Mar 20, 2023 at 09:06:04AM +0100, Uwe Kleine-König wrote:
> > > > this series adapts the platform drivers below drivers/char/tpm to use the
> > > > .remove_new() callback. 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 a
> > > > resource leak.
> > > > 
> > > > The drivers converted here returned zero in their remove callback, to the
> > > > transformation was easy.
> > > 
> > > who is responsible to pick up this patch set (or express their concerns
> > > when not applying it)?
> > > 
> > > There is (for now) no coordination necessary, the final conversion of
> > > platform_driver's remove callback is still far away. So applying it via
> > > it's usual repo would be great.
> > 
> > Please check https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git/
>
> Looking at the topmost three commits in your next branch (i.e.
> 0760dc1b2f58fe741bddb6a0030720dfd6ac4689) it looks fine to me.

OK, thanks a lot for verifying that!

BR, Jarkko

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

end of thread, other threads:[~2023-04-23 15:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20  8:06 [PATCH 0/3] tpm: Convert to platform remove callback returning void Uwe Kleine-König
2023-03-20  8:06 ` [PATCH 1/3] tpm/tpm_ftpm_tee: " Uwe Kleine-König
2023-03-20  8:06 ` [PATCH 2/3] tpm/tpm_tis: " Uwe Kleine-König
2023-03-20  8:06 ` [PATCH 3/3] tpm/tpm_tis_synquacer: " Uwe Kleine-König
2023-03-20 13:48 ` [PATCH 0/3] tpm: " Jarkko Sakkinen
2023-04-17  6:05 ` Uwe Kleine-König
2023-04-23  6:13   ` Jarkko Sakkinen
2023-04-23  8:02     ` Uwe Kleine-König
2023-04-23 15:44       ` Jarkko Sakkinen
2023-04-23  5:08 ` Jarkko Sakkinen

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).