Skip to content

Commit e9f45ef

Browse files
hfreudehcahca
authored andcommitted
s390/zcrypt: Locate ep11_domain_query_info onto the stack instead of kmalloc
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> Reviewed-by: Holger Dengler <dengler@linux.ibm.com> Link: https://lore.kernel.org/r/20250424133619.16495-18-freude@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent 9eb61e7 commit e9f45ef

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

drivers/s390/crypto/zcrypt_ep11misc.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -702,36 +702,31 @@ int ep11_get_domain_info(u16 card, u16 domain, struct ep11_domain_info *info)
702702
u8 new_WK_VP[32];
703703
u32 dom_flags;
704704
u64 op_mode;
705-
} __packed * p_dom_info;
706-
707-
p_dom_info = kmalloc(sizeof(*p_dom_info), GFP_KERNEL);
708-
if (!p_dom_info)
709-
return -ENOMEM;
705+
} __packed dom_query_info;
710706

711707
rc = ep11_query_info(card, domain, 0x03 /* domain info query */,
712-
sizeof(*p_dom_info), (u8 *)p_dom_info);
708+
sizeof(dom_query_info), (u8 *)&dom_query_info);
713709
if (rc)
714710
goto out;
715711

716712
memset(info, 0, sizeof(*info));
717713
info->cur_wk_state = '0';
718714
info->new_wk_state = '0';
719-
if (p_dom_info->dom_flags & 0x10 /* left imprint mode */) {
720-
if (p_dom_info->dom_flags & 0x02 /* cur wk valid */) {
715+
if (dom_query_info.dom_flags & 0x10 /* left imprint mode */) {
716+
if (dom_query_info.dom_flags & 0x02 /* cur wk valid */) {
721717
info->cur_wk_state = '1';
722-
memcpy(info->cur_wkvp, p_dom_info->cur_WK_VP, 32);
718+
memcpy(info->cur_wkvp, dom_query_info.cur_WK_VP, 32);
723719
}
724-
if (p_dom_info->dom_flags & 0x04 || /* new wk present */
725-
p_dom_info->dom_flags & 0x08 /* new wk committed */) {
720+
if (dom_query_info.dom_flags & 0x04 || /* new wk present */
721+
dom_query_info.dom_flags & 0x08 /* new wk committed */) {
726722
info->new_wk_state =
727-
p_dom_info->dom_flags & 0x08 ? '2' : '1';
728-
memcpy(info->new_wkvp, p_dom_info->new_WK_VP, 32);
723+
dom_query_info.dom_flags & 0x08 ? '2' : '1';
724+
memcpy(info->new_wkvp, dom_query_info.new_WK_VP, 32);
729725
}
730726
}
731-
info->op_mode = p_dom_info->op_mode;
727+
info->op_mode = dom_query_info.op_mode;
732728

733729
out:
734-
kfree(p_dom_info);
735730
return rc;
736731
}
737732
EXPORT_SYMBOL(ep11_get_domain_info);

0 commit comments

Comments
 (0)