Skip to contentSkip to conversation

tpm_crb: Check ACPI_COMPANION() against NULL during probe

PATCH In review Rafael J. Wysocki 2 participants 7 messages May 12 – Jun 9

Subsystems (3)
lore
Share & tools
lore

Rafael J. Wysocki

author maintainer
#0 lore raw

PATCH 1/1 tpm_crb: Check ACPI_COMPANION() against NULL during probe

From: "Rafael J. Wysocki" <[email protected]>

Every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), so platform drivers that rely on the existence of a device's ACPI companion object need to verify its presence.

Accordingly, add a requisite ACPI_COMPANION() check against NULL to the tpm_crb driver.

Fixes 48fe2cddc85c ("tpm_crb: Convert ACPI driver to a platform one")
---
 drivers/char/tpm/tpm_crb.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +5 -1
@@ -786,8 +786,8 @@ static int crb_map_pluton(struct device
 static int crb_acpi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct acpi_device *device = ACPI_COMPANION(dev);
 	struct acpi_table_tpm2 *buf;
+	struct acpi_device *device;
 	struct crb_priv *priv;
 	struct tpm_chip *chip;
 	struct tpm2_crb_smc *crb_smc;
@@ -797,6 +797,10 @@ static int crb_acpi_probe(struct platfor
 	u32 sm;
 	int rc;
 
+	device = ACPI_COMPANION(dev);
+	if (!device)
+		return -ENODEV;
+
 	status = acpi_get_table(ACPI_SIG_TPM2, 1,
 				(struct acpi_table_header **) &buf);
 	if (ACPI_FAILURE(status) || buf->header.length < sizeof(*buf)) {
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 32 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

Every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), so platform drivers that rely on the existence of a device's ACPI companion object need to verify its presence.

Accordingly, add a requisite ACPI_COMPANION() check against NULL to the tpm_crb driver.

Fixes 48fe2cddc85c ("tpm_crb: Convert ACPI driver to a platform one")
---
 drivers/char/tpm/tpm_crb.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +1 -1
@@ -786,8 +786,8 @@ static int crb_map_pluton(struct device
 static int crb_acpi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct acpi_device *device = ACPI_COMPANION(dev);
 	struct acpi_table_tpm2 *buf;
+	struct acpi_device *device;
 	struct crb_priv *priv;
 	struct tpm_chip *chip;
 	struct tpm2_crb_smc *crb_smc;

drivers/char/tpm/tpm_crb.c static int crb_acpi_probe(struct platfor · line 806

Quoted 10 lines
drivers/char/tpm/tpm_crb.c +4 -0
@@ -797,6 +797,10 @@ static int crb_acpi_probe(struct platfor
 	u32 sm;
 	int rc;
 
+	device = ACPI_COMPANION(dev);
+	if (!device)
+		return -ENODEV;
+
 	status = acpi_get_table(ACPI_SIG_TPM2, 1,
 				(struct acpi_table_header **) &buf);
 	if (ACPI_FAILURE(status) || buf->header.length < sizeof(*buf)) {

Thank you.

BR, Jarkko

author maintainer
#2 lore raw
Quoted 34 lines · Jarkko Sakkinen
Quoted 32 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

Every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), so platform drivers that rely on the existence of a device's ACPI companion object need to verify its presence.

Accordingly, add a requisite ACPI_COMPANION() check against NULL to the tpm_crb driver.

Fixes 48fe2cddc85c ("tpm_crb: Convert ACPI driver to a platform one")
---
 drivers/char/tpm/tpm_crb.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +1 -1
@@ -786,8 +786,8 @@ static int crb_map_pluton(struct device
 static int crb_acpi_probe(struct platform_device *pdev)
 {
      struct device *dev = &pdev->dev;
-     struct acpi_device *device = ACPI_COMPANION(dev);
      struct acpi_table_tpm2 *buf;
+     struct acpi_device *device;
      struct crb_priv *priv;
      struct tpm_chip *chip;
      struct tpm2_crb_smc *crb_smc;
@@ -797,6 +797,10 @@ static int crb_acpi_probe(struct platfor
      u32 sm;
      int rc;
 
Quoted 12 lines

drivers/char/tpm/tpm_crb.c static int crb_acpi_probe(struct platfor · line 806

Quoted 10 lines
drivers/char/tpm/tpm_crb.c +4 -0
+     device = ACPI_COMPANION(dev);
+     if (!device)
+             return -ENODEV;
+
      status = acpi_get_table(ACPI_SIG_TPM2, 1,
                              (struct acpi_table_header **) &buf);
      if (ACPI_FAILURE(status) || buf->header.length < sizeof(*buf)) {

Thanks!

So do you want me to pick up this one?

author maintainer
#3 lore raw
Quoted 49 lines · Rafael J. Wysocki
Quoted 34 lines · Jarkko Sakkinen
Quoted 32 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

Every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), so platform drivers that rely on the existence of a device's ACPI companion object need to verify its presence.

Accordingly, add a requisite ACPI_COMPANION() check against NULL to the tpm_crb driver.

Fixes 48fe2cddc85c ("tpm_crb: Convert ACPI driver to a platform one")
---
 drivers/char/tpm/tpm_crb.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +1 -1
@@ -786,8 +786,8 @@ static int crb_map_pluton(struct device
 static int crb_acpi_probe(struct platform_device *pdev)
 {
      struct device *dev = &pdev->dev;
-     struct acpi_device *device = ACPI_COMPANION(dev);
      struct acpi_table_tpm2 *buf;
+     struct acpi_device *device;
      struct crb_priv *priv;
      struct tpm_chip *chip;
      struct tpm2_crb_smc *crb_smc;
@@ -797,6 +797,10 @@ static int crb_acpi_probe(struct platfor
      u32 sm;
      int rc;
 
Quoted 12 lines

drivers/char/tpm/tpm_crb.c static int crb_acpi_probe(struct platfor · line 806

Quoted 10 lines
drivers/char/tpm/tpm_crb.c +4 -0
+     device = ACPI_COMPANION(dev);
+     if (!device)
+             return -ENODEV;
+
      status = acpi_get_table(ACPI_SIG_TPM2, 1,
                              (struct acpi_table_header **) &buf);
      if (ACPI_FAILURE(status) || buf->header.length < sizeof(*buf)) {
Quoted 3 lines

Thanks!

So do you want me to pick up this one?

I took the silence as consent and picked it up. If you'd rather route it differently, please let me know.

Thanks!

maintainer
#4 lore raw
Quoted 50 lines · Rafael J. Wysocki
Quoted 49 lines · Rafael J. Wysocki
Quoted 46 lines · Jarkko Sakkinen
Quoted 32 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

Every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), so platform drivers that rely on the existence of a device's ACPI companion object need to verify its presence.

Accordingly, add a requisite ACPI_COMPANION() check against NULL to the tpm_crb driver.

Fixes 48fe2cddc85c ("tpm_crb: Convert ACPI driver to a platform one")
---
 drivers/char/tpm/tpm_crb.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +1 -1
@@ -786,8 +786,8 @@ static int crb_map_pluton(struct device
 static int crb_acpi_probe(struct platform_device *pdev)
 {
      struct device *dev = &pdev->dev;
-     struct acpi_device *device = ACPI_COMPANION(dev);
      struct acpi_table_tpm2 *buf;
+     struct acpi_device *device;
      struct crb_priv *priv;
      struct tpm_chip *chip;
      struct tpm2_crb_smc *crb_smc;

drivers/char/tpm/tpm_crb.c static int crb_acpi_probe(struct platfor · line 806

Quoted 10 lines
drivers/char/tpm/tpm_crb.c +4 -0
@@ -797,6 +797,10 @@ static int crb_acpi_probe(struct platfor
      u32 sm;
      int rc;
 
+     device = ACPI_COMPANION(dev);
+     if (!device)
+             return -ENODEV;
+
      status = acpi_get_table(ACPI_SIG_TPM2, 1,
                              (struct acpi_table_header **) &buf);
      if (ACPI_FAILURE(status) || buf->header.length < sizeof(*buf)) {
Quoted 6 lines
Quoted 3 lines

Thanks!

So do you want me to pick up this one?

I took the silence as consent and picked it up. If you'd rather route it differently, please let me know.

OK my bad in commes, sorry. I did already pick this up and it is going to my next PR.

Quoted 2 lines

Thanks!

BR, Jarkko

author maintainer
#5 lore raw
Quoted 54 lines · Jarkko Sakkinen
Quoted 52 lines · Rafael J. Wysocki
Quoted 51 lines · Rafael J. Wysocki
Quoted 34 lines · Jarkko Sakkinen
Quoted 32 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

Every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), so platform drivers that rely on the existence of a device's ACPI companion object need to verify its presence.

Accordingly, add a requisite ACPI_COMPANION() check against NULL to the tpm_crb driver.

Fixes 48fe2cddc85c ("tpm_crb: Convert ACPI driver to a platform one")
---
 drivers/char/tpm/tpm_crb.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +1 -1
@@ -786,8 +786,8 @@ static int crb_map_pluton(struct device
 static int crb_acpi_probe(struct platform_device *pdev)
 {
      struct device *dev = &pdev->dev;
-     struct acpi_device *device = ACPI_COMPANION(dev);
      struct acpi_table_tpm2 *buf;
+     struct acpi_device *device;
      struct crb_priv *priv;
      struct tpm_chip *chip;
      struct tpm2_crb_smc *crb_smc;
@@ -797,6 +797,10 @@ static int crb_acpi_probe(struct platfor
      u32 sm;
      int rc;
 
Quoted 12 lines

drivers/char/tpm/tpm_crb.c static int crb_acpi_probe(struct platfor · line 806

Quoted 10 lines
drivers/char/tpm/tpm_crb.c +4 -0
+     device = ACPI_COMPANION(dev);
+     if (!device)
+             return -ENODEV;
+
      status = acpi_get_table(ACPI_SIG_TPM2, 1,
                              (struct acpi_table_header **) &buf);
      if (ACPI_FAILURE(status) || buf->header.length < sizeof(*buf)) {

Thanks!

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

So do you want me to pick up this one?

I took the silence as consent and picked it up. If you'd rather route it differently, please let me know.

OK my bad in commes, sorry. I did already pick this up and it is going to my next PR.

OK, I'll drop it then, thanks!

maintainer
#6 lore raw
Quoted 57 lines · Rafael J. Wysocki
Quoted 56 lines · Jarkko Sakkinen
Quoted 54 lines · Rafael J. Wysocki
Quoted 52 lines · Rafael J. Wysocki
Quoted 34 lines · Jarkko Sakkinen
Quoted 32 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

Every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), so platform drivers that rely on the existence of a device's ACPI companion object need to verify its presence.

Accordingly, add a requisite ACPI_COMPANION() check against NULL to the tpm_crb driver.

Fixes 48fe2cddc85c ("tpm_crb: Convert ACPI driver to a platform one")
---
 drivers/char/tpm/tpm_crb.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +1 -1
@@ -786,8 +786,8 @@ static int crb_map_pluton(struct device
 static int crb_acpi_probe(struct platform_device *pdev)
 {
      struct device *dev = &pdev->dev;
-     struct acpi_device *device = ACPI_COMPANION(dev);
      struct acpi_table_tpm2 *buf;
+     struct acpi_device *device;
      struct crb_priv *priv;
      struct tpm_chip *chip;
      struct tpm2_crb_smc *crb_smc;
@@ -797,6 +797,10 @@ static int crb_acpi_probe(struct platfor
      u32 sm;
      int rc;
 
Quoted 12 lines

drivers/char/tpm/tpm_crb.c static int crb_acpi_probe(struct platfor · line 806

Quoted 10 lines
drivers/char/tpm/tpm_crb.c +4 -0
+     device = ACPI_COMPANION(dev);
+     if (!device)
+             return -ENODEV;
+
      status = acpi_get_table(ACPI_SIG_TPM2, 1,
                              (struct acpi_table_header **) &buf);
      if (ACPI_FAILURE(status) || buf->header.length < sizeof(*buf)) {

Thanks!

So do you want me to pick up this one?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I took the silence as consent and picked it up. If you'd rather route it differently, please let me know.

OK my bad in commes, sorry. I did already pick this up and it is going to my next PR.

OK, I'll drop it then, thanks!

NP, and apologies for causing extra trouble!

BR, Jarkko