On Saturday, July 3, 2021 6:04 AM, Isaku Yamahata wrote: > Subject: [RFC PATCH v2 07/69] KVM: TDX: define and export helper functions > for KVM TDX support > +/* > + * Setup one-cpu-per-pkg array to do package-scoped SEAMCALLs. The > +array is > + * only necessary if there are multiple packages. > + */ > +int __init init_package_masters(void) > +{ > + int cpu, pkg, nr_filled, nr_pkgs; > + > + nr_pkgs = topology_max_packages(); > + if (nr_pkgs == 1) > + return 0; > + > + tdx_package_masters = kcalloc(nr_pkgs, sizeof(int), GFP_KERNEL); Where is the corresponding kfree() invoked? (except the one invoked on error conditions below) > + if (!tdx_package_masters) > + return -ENOMEM; > + > + memset(tdx_package_masters, -1, nr_pkgs * sizeof(int)); > + > + nr_filled = 0; > + for_each_online_cpu(cpu) { > + pkg = topology_physical_package_id(cpu); > + if (tdx_package_masters[pkg] >= 0) > + continue; > + > + tdx_package_masters[pkg] = cpu; > + if (++nr_filled == topology_max_packages()) > + break; > + } > + > + if (WARN_ON(nr_filled != topology_max_packages())) { > + kfree(tdx_package_masters); > + return -EIO; > + } Best, Wei