Re: [PATCH v2 14/20] s390/zcrypt: Locate ep11_domain_query_info onto the stack instead of kmalloc

Harald Freudenberger
2025-03-25T14:04:16Z

On 2025-03-20 15:41, Holger Dengler wrote:
> On 04/03/2025 18:21, Harald Freudenberger wrote:
>> Locate the relative small struct ep11_domain_query_info variable
>> onto the stack instead of kmalloc()/kfree().
>>
>> Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
>
> One minor comment.
> Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
>
>> ---
>> drivers/s390/crypto/zcrypt_ep11misc.c | 25 ++++++++++---------------
>> 1 file changed, 10 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/s390/crypto/zcrypt_ep11misc.c
>> b/drivers/s390/crypto/zcrypt_ep11misc.c
>> index 6005ef79c001..7fb55be3e943 100644
>> --- a/drivers/s390/crypto/zcrypt_ep11misc.c
>> +++ b/drivers/s390/crypto/zcrypt_ep11misc.c
>> @@ -790,36 +790,31 @@ int ep11_get_domain_info(u16 card, u16 domain,
>> struct ep11_domain_info *info)
>> u8 new_WK_VP[32];
>> u32 dom_flags;
>> u64 op_mode;
>> - } __packed * p_dom_info;
>> -
>> - p_dom_info = kmalloc(sizeof(*p_dom_info), GFP_KERNEL);
>> - if (!p_dom_info)
>> - return -ENOMEM;
>> + } __packed dom_query_info;
>
> Why is dom_query_info a typed struct? The struct type is not used and
> an untyped struct can be used as well.

You are right - this struct and the relevant struct for card info
are only function local and would not need a naming. However, I'll
keep these names - I think the idea was to easily copy this code
to file scope. The compiler removes it anyway.