* [PATCH] tpm: Remove dead NULL check in tpm2_flush_space()
@ 2026-04-27 16:32 Gunnar Kudrjavets
2026-04-27 20:49 ` Paul Menzel
0 siblings, 1 reply; 4+ messages in thread
From: Gunnar Kudrjavets @ 2026-04-27 16:32 UTC (permalink / raw)
To: peterhuewe, jarkko
Cc: jgg, noodles, linux-integrity, linux-kernel, Justinien Bouron
The 'space' pointer in tpm2_flush_space() is assigned from
&chip->work_space, which is the address of an embedded struct member
within struct tpm_chip. This address can never be NULL, making the
NULL check dead code. The new code follows the existing pattern
established by the other callers in tpm2-space.c which also assign
from &chip->work_space without a NULL check. Remove the dead code
to avoid confusion.
Fixes: e3aaebcbb7c6 ("tpm: Clean up TPM space after command failure")
Signed-off-by: Gunnar Kudrjavets <gunnarku@amazon.com>
Assisted-by: Kiro:claude-opus-4.6
Reviewed-by: Justinien Bouron <jbouron@amazon.com>
---
drivers/char/tpm/tpm2-space.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
index 60354cd53b5c..1eec72eb8208 100644
--- a/drivers/char/tpm/tpm2-space.c
+++ b/drivers/char/tpm/tpm2-space.c
@@ -169,9 +169,6 @@ void tpm2_flush_space(struct tpm_chip *chip)
struct tpm_space *space = &chip->work_space;
int i;
- if (!space)
- return;
-
for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++)
if (space->context_tbl[i] && ~space->context_tbl[i])
tpm2_flush_context(chip, space->context_tbl[i]);
base-commit: 949692da7211572fac419b2986b6abc0cd1aeb76
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] tpm: Remove dead NULL check in tpm2_flush_space()
2026-04-27 16:32 [PATCH] tpm: Remove dead NULL check in tpm2_flush_space() Gunnar Kudrjavets
@ 2026-04-27 20:49 ` Paul Menzel
2026-04-27 22:57 ` Gunnar Kudrjavets
0 siblings, 1 reply; 4+ messages in thread
From: Paul Menzel @ 2026-04-27 20:49 UTC (permalink / raw)
To: Gunnar Kudrjavets
Cc: peterhuewe, jarkko, jgg, noodles, linux-integrity, linux-kernel,
Justinien Bouron
Dear Gunnar,
Thank you for your patch.
Am 27.04.26 um 18:32 schrieb Gunnar Kudrjavets:
> The 'space' pointer in tpm2_flush_space() is assigned from
> &chip->work_space, which is the address of an embedded struct member
> within struct tpm_chip. This address can never be NULL, making the
> NULL check dead code. The new code follows the existing pattern
> established by the other callers in tpm2-space.c which also assign
> from &chip->work_space without a NULL check. Remove the dead code
> to avoid confusion.
>
> Fixes: e3aaebcbb7c6 ("tpm: Clean up TPM space after command failure")
> Signed-off-by: Gunnar Kudrjavets <gunnarku@amazon.com>
> Assisted-by: Kiro:claude-opus-4.6
> Reviewed-by: Justinien Bouron <jbouron@amazon.com>
> ---
> drivers/char/tpm/tpm2-space.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
> index 60354cd53b5c..1eec72eb8208 100644
> --- a/drivers/char/tpm/tpm2-space.c
> +++ b/drivers/char/tpm/tpm2-space.c
> @@ -169,9 +169,6 @@ void tpm2_flush_space(struct tpm_chip *chip)
> struct tpm_space *space = &chip->work_space;
> int i;
>
> - if (!space)
> - return;
> -
> for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++)
> if (space->context_tbl[i] && ~space->context_tbl[i])
> tpm2_flush_context(chip, space->context_tbl[i]);
gemini/gemini-3.1-pro-preview made a comment [1]. No idea, if it’s valid.
Kind regards,
Paul
[1]:
https://sashiko.dev/#/patchset/20260427163238.20230-1-gunnarku%40amazon.com
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] tpm: Remove dead NULL check in tpm2_flush_space()
2026-04-27 20:49 ` Paul Menzel
@ 2026-04-27 22:57 ` Gunnar Kudrjavets
2026-04-28 6:18 ` Paul Menzel
0 siblings, 1 reply; 4+ messages in thread
From: Gunnar Kudrjavets @ 2026-04-27 22:57 UTC (permalink / raw)
To: pmenzel
Cc: peterhuewe, jarkko, jgg, noodles, linux-integrity, linux-kernel,
jbouron, gunnarku
On Sun, Apr 27, 2026 at 10:49 PM Paul Menzel <pmenzel@molgen.mpg.de> wrote:
> gemini/gemini-3.1-pro-preview made a comment [1]. No idea, if it's valid.
Thanks for forwarding, Paul. AFAICS, the comment is a false positive.
My theory is that Gemini conflates two different variables named
'space':
1. The 'space' parameter passed to tpm_dev_transmit(). This *can* be
NULL (it is NULL for /dev/tpm0 clients).
2. The local 'space' variable inside tpm2_flush_space(). This is
assigned from &chip->work_space and can *never* be NULL.
The removed NULL check was testing case (2), not case (1).
Regards,
Gunnar
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tpm: Remove dead NULL check in tpm2_flush_space()
2026-04-27 22:57 ` Gunnar Kudrjavets
@ 2026-04-28 6:18 ` Paul Menzel
0 siblings, 0 replies; 4+ messages in thread
From: Paul Menzel @ 2026-04-28 6:18 UTC (permalink / raw)
To: Gunnar Kudrjavets
Cc: peterhuewe, jarkko, jgg, noodles, linux-integrity, linux-kernel,
jbouron
Dear Gunnar,
Am 28.04.26 um 00:57 schrieb Gunnar Kudrjavets:
> On Sun, Apr 27, 2026 at 10:49 PM Paul Menzel <pmenzel@molgen.mpg.de> wrote:
>> gemini/gemini-3.1-pro-preview made a comment [1]. No idea, if it's valid.
>
> Thanks for forwarding, Paul. AFAICS, the comment is a false positive.
>
> My theory is that Gemini conflates two different variables named
> 'space':
>
> 1. The 'space' parameter passed to tpm_dev_transmit(). This *can* be
> NULL (it is NULL for /dev/tpm0 clients).
>
> 2. The local 'space' variable inside tpm2_flush_space(). This is
> assigned from &chip->work_space and can *never* be NULL.
>
> The removed NULL check was testing case (2), not case (1).
Thank you for quickly looking into this. Sorry for the noise.
Kind regards,
Paul
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-28 6:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 16:32 [PATCH] tpm: Remove dead NULL check in tpm2_flush_space() Gunnar Kudrjavets
2026-04-27 20:49 ` Paul Menzel
2026-04-27 22:57 ` Gunnar Kudrjavets
2026-04-28 6:18 ` Paul Menzel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox