linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm, tpm_infineon: remove useless snprintf() calls
@ 2017-05-24 21:29 Jarkko Sakkinen
  2017-05-24 21:52 ` Jarkko Sakkinen
  0 siblings, 1 reply; 4+ messages in thread
From: Jarkko Sakkinen @ 2017-05-24 21:29 UTC (permalink / raw)
  To: tpmdd-devel
  Cc: linux-security-module, Jarkko Sakkinen, Peter Huewe,
	Marcel Selhorst, Jason Gunthorpe, open list

The memory copy from rodata to stack is useless.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 drivers/char/tpm/tpm_infineon.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index e3cf9f3545c5..3b1b9f9322d5 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -397,7 +397,7 @@ static int tpm_inf_pnp_probe(struct pnp_dev *dev,
 	int vendorid[2];
 	int version[2];
 	int productid[2];
-	char chipname[20];
+	const char *chipname;
 	struct tpm_chip *chip;
 
 	/* read IO-ports through PnP */
@@ -488,13 +488,13 @@ static int tpm_inf_pnp_probe(struct pnp_dev *dev,
 
 	switch ((productid[0] << 8) | productid[1]) {
 	case 6:
-		snprintf(chipname, sizeof(chipname), " (SLD 9630 TT 1.1)");
+		chipname = " (SLD 9630 TT 1.1)";
 		break;
 	case 11:
-		snprintf(chipname, sizeof(chipname), " (SLB 9635 TT 1.2)");
+		chipname = " (SLB 9635 TT 1.2)";
 		break;
 	default:
-		snprintf(chipname, sizeof(chipname), " (unknown chip)");
+		chipname = " (unknown chip)";
 		break;
 	}
 
-- 
2.11.0

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

* Re: [PATCH] tpm, tpm_infineon: remove useless snprintf() calls
  2017-05-24 21:29 [PATCH] tpm, tpm_infineon: remove useless snprintf() calls Jarkko Sakkinen
@ 2017-05-24 21:52 ` Jarkko Sakkinen
  2017-05-25  5:29   ` Aw: " Peter Huewe
  0 siblings, 1 reply; 4+ messages in thread
From: Jarkko Sakkinen @ 2017-05-24 21:52 UTC (permalink / raw)
  To: tpmdd-devel, jmorris
  Cc: linux-security-module, Peter Huewe, Marcel Selhorst,
	Jason Gunthorpe, open list

On Wed, May 24, 2017 at 02:29:16PM -0700, Jarkko Sakkinen wrote:
> The memory copy from rodata to stack is useless.
> 
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

I already applied this, reviewed-by would be nice for this one but given
how obvious this change is, it is not mandatory. I take my chances on
this one as a maitainer.

/Jarkko

> ---
>  drivers/char/tpm/tpm_infineon.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
> index e3cf9f3545c5..3b1b9f9322d5 100644
> --- a/drivers/char/tpm/tpm_infineon.c
> +++ b/drivers/char/tpm/tpm_infineon.c
> @@ -397,7 +397,7 @@ static int tpm_inf_pnp_probe(struct pnp_dev *dev,
>  	int vendorid[2];
>  	int version[2];
>  	int productid[2];
> -	char chipname[20];
> +	const char *chipname;
>  	struct tpm_chip *chip;
>  
>  	/* read IO-ports through PnP */
> @@ -488,13 +488,13 @@ static int tpm_inf_pnp_probe(struct pnp_dev *dev,
>  
>  	switch ((productid[0] << 8) | productid[1]) {
>  	case 6:
> -		snprintf(chipname, sizeof(chipname), " (SLD 9630 TT 1.1)");
> +		chipname = " (SLD 9630 TT 1.1)";
>  		break;
>  	case 11:
> -		snprintf(chipname, sizeof(chipname), " (SLB 9635 TT 1.2)");
> +		chipname = " (SLB 9635 TT 1.2)";
>  		break;
>  	default:
> -		snprintf(chipname, sizeof(chipname), " (unknown chip)");
> +		chipname = " (unknown chip)";
>  		break;
>  	}
>  
> -- 
> 2.11.0
> 

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

* Aw: Re: [PATCH] tpm, tpm_infineon: remove useless snprintf() calls
  2017-05-24 21:52 ` Jarkko Sakkinen
@ 2017-05-25  5:29   ` Peter Huewe
  2017-05-25 16:44     ` Jarkko Sakkinen
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Huewe @ 2017-05-25  5:29 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: tpmdd-devel, jmorris, linux-security-module, Marcel Selhorst,
	Jason Gunthorpe, open list

> The memory copy from rodata to stack is useless.
>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

After review, yes that should work.
Reviewed-by: Peter Huewe <peterhuewe@gmx.de>

> ---
> drivers/char/tpm/tpm_infineon.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
> index e3cf9f3545c5..3b1b9f9322d5 100644
> --- a/drivers/char/tpm/tpm_infineon.c
> +++ b/drivers/char/tpm/tpm_infineon.c
> @@ -397,7 +397,7 @@ static int tpm_inf_pnp_probe(struct pnp_dev *dev,
> int vendorid[2];
> int version[2];
> int productid[2];
> - char chipname[20];
> + const char *chipname;
> struct tpm_chip *chip;
>
> /* read IO-ports through PnP */
> @@ -488,13 +488,13 @@ static int tpm_inf_pnp_probe(struct pnp_dev *dev,
>
> switch ((productid[0] << 8) | productid[1]) {
> case 6:
> - snprintf(chipname, sizeof(chipname), " (SLD 9630 TT 1.1)");
> + chipname = " (SLD 9630 TT 1.1)";
> break;
> case 11:
> - snprintf(chipname, sizeof(chipname), " (SLB 9635 TT 1.2)");
> + chipname = " (SLB 9635 TT 1.2)";
> break;
> default:
> - snprintf(chipname, sizeof(chipname), " (unknown chip)");
> + chipname = " (unknown chip)";
> break;
> }
>
> --
> 2.11.0
>

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

* Re: Re: [PATCH] tpm, tpm_infineon: remove useless snprintf() calls
  2017-05-25  5:29   ` Aw: " Peter Huewe
@ 2017-05-25 16:44     ` Jarkko Sakkinen
  0 siblings, 0 replies; 4+ messages in thread
From: Jarkko Sakkinen @ 2017-05-25 16:44 UTC (permalink / raw)
  To: Peter Huewe
  Cc: tpmdd-devel, jmorris, linux-security-module, Marcel Selhorst,
	Jason Gunthorpe, open list

On Thu, May 25, 2017 at 07:29:05AM +0200, Peter Huewe wrote:
> > The memory copy from rodata to stack is useless.
> >
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> 
> After review, yes that should work.
> Reviewed-by: Peter Huewe <peterhuewe@gmx.de>

Yes, the string gets stored to rodata section where it is copied to
stack :-)

Thanx!

/Jarkko

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

end of thread, other threads:[~2017-05-25 16:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-24 21:29 [PATCH] tpm, tpm_infineon: remove useless snprintf() calls Jarkko Sakkinen
2017-05-24 21:52 ` Jarkko Sakkinen
2017-05-25  5:29   ` Aw: " Peter Huewe
2017-05-25 16:44     ` 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).