* [PATCH v2] crypto: ccp: Fix incorrect return type for psp_get_capability()
@ 2026-04-26 21:25 Yunseong Kim
2026-04-27 14:33 ` Tom Lendacky
0 siblings, 1 reply; 3+ messages in thread
From: Yunseong Kim @ 2026-04-26 21:25 UTC (permalink / raw)
To: Tom Lendacky, Herbert Xu, Mario Limonciello, John Allen,
David S. Miller
Cc: Yunseong Kim, linux-crypto, linux-kernel, Yunseong Kim
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.
Signed-off-by: Yunseong Kim <yunseong.kim@est.tech>
---
Changes in v2:
- Address feedback from Tom Lendacky.
---
drivers/crypto/ccp/psp-dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
index 5c7f7e02a7d8..664cd51bbf0d 100644
--- a/drivers/crypto/ccp/psp-dev.c
+++ b/drivers/crypto/ccp/psp-dev.c
@@ -141,7 +141,7 @@ 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);
---
base-commit: 7080e32d3f09d8688c4a87d81bdcc71f7f606b16
change-id: 20260426-master-eba8d68042ab
Best regards,
--
Yunseong Kim <yunseong.kim@est.tech>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] crypto: ccp: Fix incorrect return type for psp_get_capability()
2026-04-26 21:25 [PATCH v2] crypto: ccp: Fix incorrect return type for psp_get_capability() Yunseong Kim
@ 2026-04-27 14:33 ` Tom Lendacky
2026-04-27 15:24 ` Yunseong Kim
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lendacky @ 2026-04-27 14:33 UTC (permalink / raw)
To: Yunseong Kim, Herbert Xu, Mario Limonciello, John Allen,
David S. Miller
Cc: Yunseong Kim, linux-crypto, linux-kernel
On 4/26/26 16:25, Yunseong Kim wrote:
> [Some people who received this message don't often get email from yunseong.kim@est.tech. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> 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.
Not true. The psp_dev_init() function will assign the return value to an
int and so it ends up getting the -ENODEV value in the end. Also, since
psp_dev_init() is only checking for a non-zero value on error and the
return value of psp_dev_init() is not checked, this doesn't have any
impact on the processing or handling of errors.
I agree that psp_get_capability() should return an int instead of an
unsigned int, so the patch is fine, but you need to rework the commit
message to be accurate.
Thanks,
Tom
>
> Signed-off-by: Yunseong Kim <yunseong.kim@est.tech>
> ---
> Changes in v2:
> - Address feedback from Tom Lendacky.
> ---
> drivers/crypto/ccp/psp-dev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
> index 5c7f7e02a7d8..664cd51bbf0d 100644
> --- a/drivers/crypto/ccp/psp-dev.c
> +++ b/drivers/crypto/ccp/psp-dev.c
> @@ -141,7 +141,7 @@ 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);
>
>
> ---
> base-commit: 7080e32d3f09d8688c4a87d81bdcc71f7f606b16
> change-id: 20260426-master-eba8d68042ab
>
> Best regards,
> --
> Yunseong Kim <yunseong.kim@est.tech>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] crypto: ccp: Fix incorrect return type for psp_get_capability()
2026-04-27 14:33 ` Tom Lendacky
@ 2026-04-27 15:24 ` Yunseong Kim
0 siblings, 0 replies; 3+ messages in thread
From: Yunseong Kim @ 2026-04-27 15:24 UTC (permalink / raw)
To: Tom Lendacky, Herbert Xu, Mario Limonciello, John Allen,
David S. Miller
Cc: Yunseong Kim, linux-crypto@vger.kernel.org,
linux-kernel@vger.kernel.org
Hi Tom,
On 4/27/26 16:33, Tom Lendacky wrote:
> On 4/26/26 16:25, Yunseong Kim wrote:
>> [Some people who received this message don't often get email from yunseong.kim@est.tech. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>>
>> 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.
>
> Not true. The psp_dev_init() function will assign the return value to an
> int and so it ends up getting the -ENODEV value in the end. Also, since
> psp_dev_init() is only checking for a non-zero value on error and the
> return value of psp_dev_init() is not checked, this doesn't have any
> impact on the processing or handling of errors.
>
> I agree that psp_get_capability() should return an int instead of an
> unsigned int, so the patch is fine, but you need to rework the commit
> message to be accurate.
>
> Thanks,
> Tom
Oh, I see. Thanks for the comment! I’ll fix this in v3, and sorry for
being a bit late with the v2 patch.
>>
>> Signed-off-by: Yunseong Kim <yunseong.kim@est.tech>
>> ---
>> Changes in v2:
>> - Address feedback from Tom Lendacky.
>> ---
>> drivers/crypto/ccp/psp-dev.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
>> index 5c7f7e02a7d8..664cd51bbf0d 100644
>> --- a/drivers/crypto/ccp/psp-dev.c
>> +++ b/drivers/crypto/ccp/psp-dev.c
>> @@ -141,7 +141,7 @@ 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);
>>
>>
>> ---
>> base-commit: 7080e32d3f09d8688c4a87d81bdcc71f7f606b16
>> change-id: 20260426-master-eba8d68042ab
>>
>> Best regards,
>> --
>> Yunseong Kim <yunseong.kim@est.tech>
>>
Thank you,
Yunseong
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-27 15:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-26 21:25 [PATCH v2] crypto: ccp: Fix incorrect return type for psp_get_capability() Yunseong Kim
2026-04-27 14:33 ` Tom Lendacky
2026-04-27 15:24 ` Yunseong Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox