Re: [PATCH v2] crypto: ccp - unwind PSP sub-devices on partial psp_init() failure
From: Herbert Xu
Date: Fri Nov 27 2026 - 00:11:38 EST
On Mon, Nov 16, 2026 at 02:36:22PM -0600, Kim Phillips wrote:
> psp_init() initializes sub-devices sequentially but returns immediately
> on the first failure, leaving earlier sub-devices registered. Its caller
> psp_dev_init() then sets sp->psp_data = NULL, so the later
> psp_dev_destroy() on unbind bails out early and never unregisters them.
>
> Non-devm resources such as the /dev/sev and /dev/dbc character devices
> stay globally visible while their devm-allocated backing structures are
> freed by the driver core, giving a use-after-free if userspace opens the
> orphaned device.
>
> Add reverse-order unwind labels to psp_init() so each sub-device is torn
> down before the error is propagated. Every *_dev_destroy() is already
> NULL-guarded on its own psp->*_data pointer, so skipped or unreached
> sub-devices are no-ops.
>
> sp_init() continues to ignore the psp_dev_init() return value on
> purpose: a PSP failure must not fail the probe, as the CCP can still
> initialize successfully.
>
> Fixes: 33960acccfbd ("crypto: ccp - add TEE support for Raven Ridge")
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Closes: https://sashiko.dev/#/bug/linux-0de87f0c-0f5a-4dad-8ef1-f49844eb4cce
> Cc: Tom Lendacky <thomas.lendacky@xxxxxxx>
> Cc: Rijo Thomas <Rijo-john.Thomas@xxxxxxx>
> Cc: Mario Limonciello <mario.limonciello@xxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Kim Phillips <kim.phillips@xxxxxxx>
> ---
> v1: https://lore.kernel.org/linux-crypto/20261021215716.1076732-1-kim.phillips@xxxxxxx/
>
> drivers/crypto/ccp/psp-dev.c | 23 ++++++++++++++++++-----
> 1 file changed, 18 insertions(+), 5 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt