# Re: \[PATCH v6 2/9\] keys/trusted\_keys: fix PKWM output buffer cleanup

- From: Jarkko Sakkinen \<jarkko@kernel.org\>
- Date: 2026-11-05 17:12:11 
- List: linux-security-module
- Page: https://ratatoskr.run/linux-security-module/2026/11/17872502
- Thread: https://ratatoskr.run/linux-integrity/2026/11/17871225/t.md

```text
On Thu, Nov 05, 2026 at 08:13:13PM +0530, Srish Srinivasan wrote:
> The PKWM seal and unseal paths unconditionally free their output buffers,
> but the PLPKS helpers can return without initializing those pointers.
> 
> Initialize the output buffer pointers to NULL to make cleanup safe on early
> failure paths.
> 
> Fixes: c99fcb0d735b ("keys/trusted_keys: establish PKWM as a trusted source")
> Cc: <redacted> # 7.0
> Signed-off-by: Srish Srinivasan <ssrish@linux.ibm.com>
> ---
>  security/keys/trusted-keys/trusted_pkwm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/security/keys/trusted-keys/trusted_pkwm.c b/security/keys/trusted-keys/trusted_pkwm.c
> index 422f752598e1..97ffec0ce1b7 100644
> --- a/security/keys/trusted-keys/trusted_pkwm.c
> +++ b/security/keys/trusted-keys/trusted_pkwm.c
> @@ -82,7 +82,7 @@ static int trusted_pkwm_seal(struct trusted_key_payload *p, char *datablob)
>  {
>  	struct trusted_key_options *options = NULL;
>  	struct trusted_pkwm_options *pkwm = NULL;
> -	u8 *input_buf, *output_buf;
> +	u8 *input_buf, *output_buf = NULL;
>  	u32 output_len, input_len;
>  	int rc;
>  
> @@ -129,7 +129,7 @@ static int trusted_pkwm_seal(struct trusted_key_payload *p, char *datablob)
>  
>  static int trusted_pkwm_unseal(struct trusted_key_payload *p, char *datablob)
>  {
> -	u8 *input_buf, *output_buf;
> +	u8 *input_buf, *output_buf = NULL;
>  	u32 input_len, output_len;
>  	int rc;
>  
> -- 
> 2.52.0
> 

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

Br, Jarkko

```
