Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Harald Freudenberger and committed by
Heiko Carstens
e9f45ef6 9eb61e71

+10 -15
+10 -15
drivers/s390/crypto/zcrypt_ep11misc.c
··· 702 702 u8 new_WK_VP[32]; 703 703 u32 dom_flags; 704 704 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; 710 706 711 707 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); 713 709 if (rc) 714 710 goto out; 715 711 716 712 memset(info, 0, sizeof(*info)); 717 713 info->cur_wk_state = '0'; 718 714 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 */) { 721 717 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); 723 719 } 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 */) { 726 722 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); 729 725 } 730 726 } 731 - info->op_mode = p_dom_info->op_mode; 727 + info->op_mode = dom_query_info.op_mode; 732 728 733 729 out: 734 - kfree(p_dom_info); 735 730 return rc; 736 731 } 737 732 EXPORT_SYMBOL(ep11_get_domain_info);