[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <287919c7-b268-4dbe-910a-9b42d62a9094@kernel.org>
Date: Wed, 3 Sep 2025 09:53:54 -0500
From: Mario Limonciello <superm1@...nel.org>
To: Yunseong Kim <ysk@...lloc.com>, Herbert Xu <herbert@...dor.apana.org.au>,
Tom Lendacky <thomas.lendacky@....com>, John Allen <john.allen@....com>,
"David S. Miller" <davem@...emloft.net>
Cc: linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] crypto: ccp: Fix incorrect return type for
psp_get_capability()
On 9/3/25 8:55 AM, Yunseong Kim wrote:
> psp_get_capability() is declared as returning an 'unsigned int'. However,
> it returns -ENODEV on failure when it cannot access the device registers
> (i.e., when ioread32 returns 0xffffffff).
>
> Since -ENODEV is a negative value, returning it from a function declared as
> 'unsigned int' results in an implicit cast to a large positive integer.
> This prevents the caller psp_dev_init() from correctly detecting the
> error condition, leading to improper error handling.
>
> Fix this by changing the return type of psp_get_capability() to 'int'.
>
> Additionally, change the type of the local variable 'val' to 'u32', which
> is more appropriate for register access, and reformat the long dev_notice
> line to adhere to kernel coding style guidelines.
>
> Signed-off-by: Yunseong Kim <ysk@...lloc.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@...nel.org>
> ---
> drivers/crypto/ccp/psp-dev.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
> index 1c5a7189631e..84dde53db25b 100644
> --- a/drivers/crypto/ccp/psp-dev.c
> +++ b/drivers/crypto/ccp/psp-dev.c
> @@ -140,9 +140,9 @@ static irqreturn_t psp_irq_handler(int irq, void *data)
> return IRQ_HANDLED;
> }
>
> -static unsigned int psp_get_capability(struct psp_device *psp)
> +static int psp_get_capability(struct psp_device *psp)
> {
> - unsigned int val = ioread32(psp->io_regs + psp->vdata->feature_reg);
> + u32 val = ioread32(psp->io_regs + psp->vdata->feature_reg);
>
> /*
> * Check for a access to the registers. If this read returns
> @@ -152,7 +152,8 @@ static unsigned int psp_get_capability(struct psp_device *psp)
> * could get properly initialized).
> */
> if (val == 0xffffffff) {
> - dev_notice(psp->dev, "psp: unable to access the device: you might be running a broken BIOS.\n");
> + dev_notice(psp->dev,
> + "psp: unable to access the device: you might be running a broken BIOS.\n");
> return -ENODEV;
> }
> psp->capability.raw = val;
Powered by blists - more mailing lists