Skip to contentSkip to conversation

tpm: assorted fixes and cleanups

PATCH In review Pei Xiao 3 participants 17 messages Oct 3 – Oct 5

Subsystems (2)
lore
Share & tools
lore

Pei Xiao

author
#0 lore raw

cover tpm: assorted fixes and cleanups

This series fixes several issues found during a code review of drivers/char/tpm:

1. tpm_ppi: tpm_show_ppi_response() stores its return value in an acpi_status (a u32 typedef), so error codes such as -EINVAL reach user space as huge positive values. Declare the variable as ssize_t to match the show callback's return type.

2. tpm_nsc: tpm_nsc_remove() doubles as the release callback of the hand-created platform device and dereferences the chip drvdata unconditionally; init failures before tpmm_chip_alloc() crash module load. Return early when the chip has not been created.

3. tpm_nsc: the cleanup runs twice on module exit because tpm_nsc_remove() is both the explicit cleanup and the device release callback; the second run operates on an already freed chip. Stop overriding the release callback, which also stops the platform object allocation from leaking.

4. tpm_dev: a zero-length read() discards a pending response, breaking the command/response pairing of the TPM character devices, although POSIX requires zero-count reads to have no side effects. Return early on a zero count.

5. tpm-interface: make the tpm_init() error messages consistently prefixed with "tpm: " and report the actual failure of tpm_dev_common_init().

The series was prepared with AI assistance (GLM-5.3); every change was reviewed against the code by hand.

Pei Xiao (5):
tpm: tpm_ppi: fix wrong error code returned to user space
tpm: tpm_nsc: fix NULL pointer dereference on init failure
tpm: tpm_nsc: stop using the cleanup callback as dev.release
tpm: fix zero-length read discarding the pending response
tpm: fix log messages in tpm_init()

 drivers/char/tpm/tpm-dev-common.c | 3 +++
 drivers/char/tpm/tpm-interface.c  | 6 +++---
 drivers/char/tpm/tpm_nsc.c        | 8 ++++++--
 drivers/char/tpm/tpm_ppi.c        | 2 +-
 4 files changed, 13 insertions(+), 6 deletions(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/5 tpm: tpm_ppi: fix wrong error code returned to user space

tpm_show_ppi_response() stores its return value in an acpi_status, a typedef of u32. Both error paths of the function (-EINVAL on a malformed _DSM package, -EFAULT on a non-zero operation return code) end up as huge positive values when returned as ssize_t, so user space cannot detect the failure with the usual "ret < 0" check.

Declare the variable as ssize_t to match the show callback's return type.

Fixes 84b1667dea23 ("ACPI / TPM: replace open-coded _DSM code with helper functions")
Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm_ppi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_ppi.c +1 -1
index c9793a3d986d..949fb7055bea 100644
@@ -234,7 +234,7 @@ static ssize_t tpm_show_ppi_response(struct device *dev,
 				     struct device_attribute *attr,
 				     char *buf)
 {
-	acpi_status status = -EINVAL;
+	ssize_t status = -EINVAL;
 	union acpi_object *obj, *ret_obj;
 	u64 req, res;
 	struct tpm_chip *chip = to_tpm_chip(dev);
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/5] tpm: tpm_ppi: fix wrong error code returned to user space

Quoted 6 lines · Pei Xiao

tpm_show_ppi_response() stores its return value in an acpi_status, a typedef of u32. Both error paths of the function (-EINVAL on a malformed _DSM package, -EFAULT on a non-zero operation return code) end up as huge positive values when returned as ssize_t, so user space cannot detect the failure with the usual "ret < 0" check.

I have no idea what you mean by huge value and why that would be a problem, and overall this is disconnected from the code change.

Two's complement value is correctly stored in status up until the ssize_t cast, which results the value to be zero-extended, and as a result corrupt the negative values.

Quoted 27 lines

Declare the variable as ssize_t to match the show callback's return type.

Fixes 84b1667dea23 ("ACPI / TPM: replace open-coded _DSM code with helper functions")
Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm_ppi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_ppi.c +1 -1
index c9793a3d986d..949fb7055bea 100644
@@ -234,7 +234,7 @@ static ssize_t tpm_show_ppi_response(struct device *dev,
 				     struct device_attribute *attr,
 				     char *buf)
 {
-	acpi_status status = -EINVAL;
+	ssize_t status = -EINVAL;
 	union acpi_object *obj, *ret_obj;
 	u64 req, res;
 	struct tpm_chip *chip = to_tpm_chip(dev);
Signature · 1 line
2.25.1

Br, Jarkko

author
#3 lore raw

Re: [PATCH 1/5] tpm: tpm_ppi: fix wrong error code returned to user space

Quoted 8 lines · Jarkko Sakkinen
Quoted 6 lines · Pei Xiao

tpm_show_ppi_response() stores its return value in an acpi_status, a typedef of u32. Both error paths of the function (-EINVAL on a malformed _DSM package, -EFAULT on a non-zero operation return code) end up as huge positive values when returned as ssize_t, so user space cannot detect the failure with the usual "ret < 0" check.

Quoted 6 lines

I have no idea what you mean by huge value and why that would be a problem, and overall this is disconnected from the code change.

Two's complement value is correctly stored in status up until the ssize_t cast, which results the value to be zero-extended, and as a result corrupt the negative values.

How does the following Git commit message look:

tpm: tpm_ppi: fix zero-extension of negative error codes

tpm_show_ppi_response() keeps its return value in an acpi_status, a typedef of u32. The two's complement of the error code is stored correctly there, but on return the value is converted to ssize_t and zero-extended, so the sign is lost: user space receives 0xFFFFFFEA (4294967274) instead of -EINVAL, which breaks the usual "ret < 0" error check.
Declare the variable as ssize_t so that negative values survive the conversion.

Quoted 30 lines
Quoted 28 lines

Declare the variable as ssize_t to match the show callback's return type.

Fixes 84b1667dea23 ("ACPI / TPM: replace open-coded _DSM code with helper functions")
Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm_ppi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_ppi.c +1 -1
index c9793a3d986d..949fb7055bea 100644
@@ -234,7 +234,7 @@ static ssize_t tpm_show_ppi_response(struct device *dev,
 				     struct device_attribute *attr,
 				     char *buf)
 {
-	acpi_status status = -EINVAL;
+	ssize_t status = -EINVAL;
 	union acpi_object *obj, *ret_obj;
 	u64 req, res;
 	struct tpm_chip *chip = to_tpm_chip(dev);
Signature · 1 line
2.25.1

Br, Jarkko

maintainer
#4 lore raw

Re: [PATCH 1/5] tpm: tpm_ppi: fix wrong error code returned to user space

Quoted 21 lines · Pei Xiao
Quoted 8 lines · Jarkko Sakkinen
Quoted 6 lines · Pei Xiao

tpm_show_ppi_response() stores its return value in an acpi_status, a typedef of u32. Both error paths of the function (-EINVAL on a malformed _DSM package, -EFAULT on a non-zero operation return code) end up as huge positive values when returned as ssize_t, so user space cannot detect the failure with the usual "ret < 0" check.

Quoted 6 lines

I have no idea what you mean by huge value and why that would be a problem, and overall this is disconnected from the code change.

Two's complement value is correctly stored in status up until the ssize_t cast, which results the value to be zero-extended, and as a result corrupt the negative values.

How does the following Git commit message look:

tpm: tpm_ppi: fix zero-extension of negative error codes

Quoted 8 lines

tpm_show_ppi_response() keeps its return value in an acpi_status, a typedef of u32. The two's complement of the error code is stored correctly there, but on return the value is converted to ssize_t and zero-extended, so the sign is lost: user space receives 0xFFFFFFEA (4294967274) instead of -EINVAL, which breaks the usual "ret < 0" error check.
Declare the variable as ssize_t so that negative values survive the conversion.

Works for me. It does not have to be perfect as long as it points out to the right direction.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

Declare the variable as ssize_t to match the show callback's return type.

Fixes 84b1667dea23 ("ACPI / TPM: replace open-coded _DSM code with helper functions")
Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm_ppi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_ppi.c +1 -1
index c9793a3d986d..949fb7055bea 100644
@@ -234,7 +234,7 @@ static ssize_t tpm_show_ppi_response(struct device *dev,
 				     struct device_attribute *attr,
 				     char *buf)
 {
-	acpi_status status = -EINVAL;
+	ssize_t status = -EINVAL;
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
drivers/char/tpm/tpm_ppi.c +0 -0
 	union acpi_object *obj, *ret_obj;
 	u64 req, res;
 	struct tpm_chip *chip = to_tpm_chip(dev);
Signature · 1 line
2.25.1

Br, Jarkko

Br, Jarkko

author
#5 lore raw

PATCH 2/5 tpm: tpm_nsc: fix NULL pointer dereference on init failure

In reply to Pei Xiao

tpm_nsc_remove() is used as the release callback of the hand-created platform device and dereferences the chip drvdata unconditionally. If init fails before tpmm_chip_alloc() (e.g. request_region() cannot claim the ports), the error path drops the last device reference and the release callback runs with chip == NULL, crashing module init.

Return early when the chip has not been created yet.

Fixes afb5abc262e9 ("tpm: two-phase chip management functions")
Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm_nsc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_nsc.c +6 -1
index 879ac88f5783..46a52dc99b14 100644
@@ -259,7 +259,12 @@ static struct platform_device *pdev = NULL;
 static void tpm_nsc_remove(struct device *dev)
 {
 	struct tpm_chip *chip = dev_get_drvdata(dev);
-	struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
+	struct tpm_nsc_priv *priv;
+
+	if (!chip)
+		return;
+
+	priv = dev_get_drvdata(&chip->dev);
 
 	tpm_chip_unregister(chip);
 	release_region(priv->base, 2);
Signature · 1 line
2.25.1
Reviewed-by on v1 2/5
#6 lore raw

Re: [PATCH 2/5] tpm: tpm_nsc: fix NULL pointer dereference on init failure

Quoted 36 lines · Pei Xiao

tpm_nsc_remove() is used as the release callback of the hand-created platform device and dereferences the chip drvdata unconditionally. If init fails before tpmm_chip_alloc() (e.g. request_region() cannot claim the ports), the error path drops the last device reference and the release callback runs with chip == NULL, crashing module init.

Return early when the chip has not been created yet.

Fixes afb5abc262e9 ("tpm: two-phase chip management functions")
Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm_nsc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_nsc.c +6 -1
index 879ac88f5783..46a52dc99b14 100644
@@ -259,7 +259,12 @@ static struct platform_device *pdev = NULL;
 static void tpm_nsc_remove(struct device *dev)
 {
 	struct tpm_chip *chip = dev_get_drvdata(dev);
-	struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
+	struct tpm_nsc_priv *priv;
+
+	if (!chip)
+		return;
+
+	priv = dev_get_drvdata(&chip->dev);
 
 	tpm_chip_unregister(chip);
 	release_region(priv->base, 2);
Signature · 1 line
2.25.1

I can apply this, thanks.

Br, Jarkko

author
#7 lore raw

PATCH 3/5 tpm: tpm_nsc: stop using the cleanup callback as dev.release

In reply to Pei Xiao

tpm_nsc_remove() is called explicitly from cleanup_nsc() and also runs as the platform device release callback on the final platform_device_put(), so the cleanup executes twice on module exit; the second invocation operates on a chip that has already been freed by the devm cleanup, and the I/O region is released twice.

Overwriting the release callback installed by platform_device_alloc() also keeps platform_device_release() from running, leaking the platform object allocation.

Leave the default release callback in place; the explicit call in cleanup_nsc() remains the single cleanup point.

Fixes 570302a31149 ("[PATCH] tpm: move nsc driver off pci_dev")
Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm_nsc.c | 1 -
 1 file changed, 1 deletion(-)
drivers/char/tpm/tpm_nsc.c +0 -1
index 46a52dc99b14..bcfa2a1a208a 100644
@@ -327,7 +327,6 @@ static int __init init_nsc(void)
 
 	pdev->num_resources = 0;
 	pdev->dev.driver = &nsc_drv.driver;
-	pdev->dev.release = tpm_nsc_remove;
 
 	if ((rc = platform_device_add(pdev)) < 0)
 		goto err_put_dev;
Signature · 1 line
2.25.1
Reviewed-by on v1 3/5
#8 lore raw

Re: [PATCH 3/5] tpm: tpm_nsc: stop using the cleanup callback as dev.release

Quoted 36 lines · Pei Xiao

tpm_nsc_remove() is called explicitly from cleanup_nsc() and also runs as the platform device release callback on the final platform_device_put(), so the cleanup executes twice on module exit; the second invocation operates on a chip that has already been freed by the devm cleanup, and the I/O region is released twice.

Overwriting the release callback installed by platform_device_alloc() also keeps platform_device_release() from running, leaking the platform object allocation.

Leave the default release callback in place; the explicit call in cleanup_nsc() remains the single cleanup point.

Fixes 570302a31149 ("[PATCH] tpm: move nsc driver off pci_dev")
Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm_nsc.c | 1 -
 1 file changed, 1 deletion(-)
drivers/char/tpm/tpm_nsc.c +0 -1
index 46a52dc99b14..bcfa2a1a208a 100644
@@ -327,7 +327,6 @@ static int __init init_nsc(void)
 
 	pdev->num_resources = 0;
 	pdev->dev.driver = &nsc_drv.driver;
-	pdev->dev.release = tpm_nsc_remove;
 
 	if ((rc = platform_device_add(pdev)) < 0)
 		goto err_put_dev;
Signature · 1 line
2.25.1

This is fine too, thanks.

Br, Jarkko

author
#9 lore raw

PATCH 4/5 tpm: fix zero-length read discarding the pending response

In reply to Pei Xiao

POSIX requires that a read() with a count of zero returns zero and has no other effects. tpm_common_read() treats such a call as a consumed response: it marks the pending response as read and drops it, so the response can never be retrieved; subsequent reads return zero and the next write() is allowed to overwrite the response buffer, silently breaking the command/response pairing of the TPM character devices.

Return early when the caller passes a zero count, leaving any pending response untouched for the next read. A zero-length read will not report a deferred asynchronous error; POSIX permits read() to skip error detection for a zero count.

Fixes 9488585b21be ("tpm: add support for partial reads")
Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm-dev-common.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/char/tpm/tpm-dev-common.c +3 -0
index f942c0c8e402..6569212dc6b8 100644
@@ -134,6 +134,9 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
 	ssize_t ret_size = 0;
 	int rc;
 
+	if (!size)
+		return 0;
+
 	mutex_lock(&priv->buffer_mutex);
 
 	if (priv->response_length) {
Signature · 1 line
2.25.1
Reviewed-by on v1 4/5
#10 lore raw

Re: [PATCH 4/5] tpm: fix zero-length read discarding the pending response

Quoted 37 lines · Pei Xiao

POSIX requires that a read() with a count of zero returns zero and has no other effects. tpm_common_read() treats such a call as a consumed response: it marks the pending response as read and drops it, so the response can never be retrieved; subsequent reads return zero and the next write() is allowed to overwrite the response buffer, silently breaking the command/response pairing of the TPM character devices.

Return early when the caller passes a zero count, leaving any pending response untouched for the next read. A zero-length read will not report a deferred asynchronous error; POSIX permits read() to skip error detection for a zero count.

Fixes 9488585b21be ("tpm: add support for partial reads")
Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm-dev-common.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/char/tpm/tpm-dev-common.c +3 -0
index f942c0c8e402..6569212dc6b8 100644
@@ -134,6 +134,9 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
 	ssize_t ret_size = 0;
 	int rc;
 
+	if (!size)
+		return 0;
+
 	mutex_lock(&priv->buffer_mutex);
 
 	if (priv->response_length) {
Signature · 1 line
2.25.1

This look good to me, thanks.

Br, Jarkko

author
#11 lore raw

PATCH 5/5 tpm: fix log messages in tpm_init()

In reply to Pei Xiao

Make the error messages consistently prefixed with "tpm: ", and fix the tpm_dev_common_init() failure message which was wrongly copied from the previous step.

Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm-interface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +3 -3
index 1ccdbde98b69..666a1c654c02 100644
@@ -524,13 +524,13 @@ static int __init tpm_init(void)
 
 	rc = class_register(&tpm_class);
 	if (rc) {
-		pr_err("couldn't create tpm class\n");
+		pr_err("tpm: couldn't create tpm class\n");
 		return rc;
 	}
 
 	rc = class_register(&tpmrm_class);
 	if (rc) {
-		pr_err("couldn't create tpmrm class\n");
+		pr_err("tpm: couldn't create tpmrm class\n");
 		goto out_destroy_tpm_class;
 	}
 
@@ -542,7 +542,7 @@ static int __init tpm_init(void)
 
 	rc = tpm_dev_common_init();
 	if (rc) {
-		pr_err("tpm: failed to allocate char dev region\n");
+		pr_err("tpm: failed to allocate TPM workqueue\n");
 		goto out_unreg_chrdev;
 	}
 
Signature · 1 line
2.25.1
#12 lore raw

Re: [PATCH 5/5] tpm: fix log messages in tpm_init()

Quoted 42 lines · Pei Xiao

Make the error messages consistently prefixed with "tpm: ", and fix the tpm_dev_common_init() failure message which was wrongly copied from the previous step.

Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm-interface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +3 -3
index 1ccdbde98b69..666a1c654c02 100644
@@ -524,13 +524,13 @@ static int __init tpm_init(void)
 
 	rc = class_register(&tpm_class);
 	if (rc) {
-		pr_err("couldn't create tpm class\n");
+		pr_err("tpm: couldn't create tpm class\n");
 		return rc;
 	}
 
 	rc = class_register(&tpmrm_class);
 	if (rc) {
-		pr_err("couldn't create tpmrm class\n");
+		pr_err("tpm: couldn't create tpmrm class\n");
 		goto out_destroy_tpm_class;
 	}
 
@@ -542,7 +542,7 @@ static int __init tpm_init(void)
 
 	rc = tpm_dev_common_init();
 	if (rc) {
-		pr_err("tpm: failed to allocate char dev region\n");
+		pr_err("tpm: failed to allocate TPM workqueue\n");
 		goto out_unreg_chrdev;
 	}
 
Signature · 1 line
2.25.1

I NAK this one. It is not fixing anything.

Br, Jarkko

author
#13 lore raw

Re: [PATCH 5/5] tpm: fix log messages in tpm_init()

Quoted 40 lines · Jarkko Sakkinen
Quoted 39 lines · Pei Xiao

Make the error messages consistently prefixed with "tpm: ", and fix the tpm_dev_common_init() failure message which was wrongly copied from the previous step.

Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm-interface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +3 -3
index 1ccdbde98b69..666a1c654c02 100644
@@ -524,13 +524,13 @@ static int __init tpm_init(void)
 
 	rc = class_register(&tpm_class);
 	if (rc) {
-		pr_err("couldn't create tpm class\n");
+		pr_err("tpm: couldn't create tpm class\n");
 		return rc;
 	}
 
 	rc = class_register(&tpmrm_class);
 	if (rc) {
-		pr_err("couldn't create tpmrm class\n");
+		pr_err("tpm: couldn't create tpmrm class\n");
 		goto out_destroy_tpm_class;
 	}
 
@@ -542,7 +542,7 @@ static int __init tpm_init(void)
 
 	rc = tpm_dev_common_init();
 	if (rc) {
-		pr_err("tpm: failed to allocate char dev region\n");
+		pr_err("tpm: failed to allocate TPM workqueue\n");
 		goto out_unreg_chrdev;
 	}
 
Quoted 5 lines
Quoted 3 lines
Signature · 1 line
2.25.1

I NAK this one. It is not fixing anything.

Hmm, this is a cleanup, not a fix—just a very minor change to an error log/print. I noticed it was duplicated (with the alloc_chrdev_region error print), which made it impossible to tell which function call had failed (it might actually never be executed). So I just brought up this cleanup along the way.

Pei.
Thanks!>

Quoted 1 line

Br, Jarkko

maintainer
#14 lore raw

Re: [PATCH 5/5] tpm: fix log messages in tpm_init()

Quoted 48 lines · Pei Xiao
Quoted 40 lines · Jarkko Sakkinen
Quoted 39 lines · Pei Xiao

Make the error messages consistently prefixed with "tpm: ", and fix the tpm_dev_common_init() failure message which was wrongly copied from the previous step.

Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm-interface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +3 -3
index 1ccdbde98b69..666a1c654c02 100644
@@ -524,13 +524,13 @@ static int __init tpm_init(void)
 
 	rc = class_register(&tpm_class);
 	if (rc) {
-		pr_err("couldn't create tpm class\n");
+		pr_err("tpm: couldn't create tpm class\n");
 		return rc;
 	}
 
 	rc = class_register(&tpmrm_class);
 	if (rc) {
-		pr_err("couldn't create tpmrm class\n");
+		pr_err("tpm: couldn't create tpmrm class\n");
 		goto out_destroy_tpm_class;
 	}
 
@@ -542,7 +542,7 @@ static int __init tpm_init(void)
 
 	rc = tpm_dev_common_init();
 	if (rc) {
-		pr_err("tpm: failed to allocate char dev region\n");
+		pr_err("tpm: failed to allocate TPM workqueue\n");
 		goto out_unreg_chrdev;
 	}
 
Quoted 5 lines
Quoted 3 lines
Signature · 1 line
2.25.1

I NAK this one. It is not fixing anything.

Quoted 5 lines

Hmm, this is a cleanup, not a fix—just a very minor change to an error log/print. I noticed it was duplicated (with the alloc_chrdev_region error print), which made it impossible to tell which function call had failed (it might actually never be executed). So I just brought up this cleanup along the way.

If there is patch that is coming along the way, it is patch that should not be sent because:

1. It wastes also everyone else's time.
2. Lack of understanding of cause and effect because by definition you have no idea what you are submitting. E

Pure clean ups per se are already something that is usually best to NAK but this patch is not a clean up.

I mean the path is doing arbitrary log message changes. That is not harmless change as you enforce your arbitrary preferences also for few billion other users.

Br, Jarkko

author
#15 lore raw

Re: [PATCH 5/5] tpm: fix log messages in tpm_init()

Quoted 62 lines · Jarkko Sakkinen
Quoted 48 lines · Pei Xiao
Quoted 40 lines · Jarkko Sakkinen
Quoted 39 lines · Pei Xiao

Make the error messages consistently prefixed with "tpm: ", and fix the tpm_dev_common_init() failure message which was wrongly copied from the previous step.

Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm-interface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +3 -3
index 1ccdbde98b69..666a1c654c02 100644
@@ -524,13 +524,13 @@ static int __init tpm_init(void)
 
 	rc = class_register(&tpm_class);
 	if (rc) {
-		pr_err("couldn't create tpm class\n");
+		pr_err("tpm: couldn't create tpm class\n");
 		return rc;
 	}
 
 	rc = class_register(&tpmrm_class);
 	if (rc) {
-		pr_err("couldn't create tpmrm class\n");
+		pr_err("tpm: couldn't create tpmrm class\n");
 		goto out_destroy_tpm_class;
 	}
 
@@ -542,7 +542,7 @@ static int __init tpm_init(void)
 
 	rc = tpm_dev_common_init();
 	if (rc) {
-		pr_err("tpm: failed to allocate char dev region\n");
+		pr_err("tpm: failed to allocate TPM workqueue\n");
 		goto out_unreg_chrdev;
 	}
 
Quoted 5 lines
Quoted 3 lines
Signature · 1 line
2.25.1

I NAK this one. It is not fixing anything.

Quoted 5 lines

Hmm, this is a cleanup, not a fix—just a very minor change to an error log/print. I noticed it was duplicated (with the alloc_chrdev_region error print), which made it impossible to tell which function call had failed (it might actually never be executed). So I just brought up this cleanup along the way.

If there is patch that is coming along the way, it is patch that should not be sent because:

1. It wastes also everyone else's time.
2. Lack of understanding of cause and effect because by definition you have no idea what you are submitting. E

Quoted 6 lines

Pure clean ups per se are already something that is usually best to NAK but this patch is not a clean up.

I mean the path is doing arbitrary log message changes. That is not harmless change as you enforce your arbitrary preferences also for few billion other users.

OK, got it. Thanks.

Quoted 2 lines

Br, Jarkko

maintainer
#16 lore raw

Re: [PATCH 5/5] tpm: fix log messages in tpm_init()

In reply to Jarkko Sakkinen
Quoted 62 lines · Jarkko Sakkinen
Quoted 48 lines · Pei Xiao
Quoted 40 lines · Jarkko Sakkinen
Quoted 39 lines · Pei Xiao

Make the error messages consistently prefixed with "tpm: ", and fix the tpm_dev_common_init() failure message which was wrongly copied from the previous step.

Assisted-by GLM-5.3
---
 drivers/char/tpm/tpm-interface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +3 -3
index 1ccdbde98b69..666a1c654c02 100644
@@ -524,13 +524,13 @@ static int __init tpm_init(void)
 
 	rc = class_register(&tpm_class);
 	if (rc) {
-		pr_err("couldn't create tpm class\n");
+		pr_err("tpm: couldn't create tpm class\n");
 		return rc;
 	}
 
 	rc = class_register(&tpmrm_class);
 	if (rc) {
-		pr_err("couldn't create tpmrm class\n");
+		pr_err("tpm: couldn't create tpmrm class\n");
 		goto out_destroy_tpm_class;
 	}
 
@@ -542,7 +542,7 @@ static int __init tpm_init(void)
 
 	rc = tpm_dev_common_init();
 	if (rc) {
-		pr_err("tpm: failed to allocate char dev region\n");
+		pr_err("tpm: failed to allocate TPM workqueue\n");
 		goto out_unreg_chrdev;
 	}
 
Quoted 5 lines
Quoted 3 lines
Signature · 1 line
2.25.1

I NAK this one. It is not fixing anything.

Quoted 5 lines

Hmm, this is a cleanup, not a fix—just a very minor change to an error log/print. I noticed it was duplicated (with the alloc_chrdev_region error print), which made it impossible to tell which function call had failed (it might actually never be executed). So I just brought up this cleanup along the way.

If there is patch that is coming along the way, it is patch that should not be sent because:

1. It wastes also everyone else's time.
2. Lack of understanding of cause and effect because by definition you have no idea what you are submitting. E

Quoted 6 lines

Pure clean ups per se are already something that is usually best to NAK but this patch is not a clean up.

I mean the path is doing arbitrary log message changes. That is not harmless change as you enforce your arbitrary preferences also for few billion other users.

Well, maybe just machines but anyhow :-)

Br, Jarkko