On 7/1/26 4:48 PM, Zhuoying Cai wrote:
> +static int handle_diag320_store_vc(S390CPU *cpu, uint64_t addr, uint64_t r1,
> uintptr_t ra,
> + S390IPLCertificateStore *cs)
...
> + g_autofree VCEntry *vce = g_malloc0(vce_max_len);
You are allocating with g_autofree here..
> +
> + /*
> + * Bit 0 of the VCE flags indicates whether the certificate is valid.
> + * The caller of DIAG320 subcode 2 is responsible for verifying that
> + * the VCE contains a valid certificate.
> + */
> + if (build_vce_header(vce, cert, i) || build_vce_data(vce, cert,
> vce_max_len)) {
> + /*
> + * Error occurs - VCE does not contain a valid certificate.
> + * Bit 0 of the VCE flags is 0 and the VCE length is set.
> + */
> + vce->vce_hdr.len = cpu_to_be32(VCE_INVALID_LEN);
> + }
> + vce_len = be32_to_cpu(vce->vce_hdr.len);
> +
> + /*
> + * If there is no more space to store the cert,
> + * set the remaining verification cert count and
> + * break early.
> + */
> + if (remaining_space < vce_len) {
> + vcb_hdr->remain_ct = cpu_to_be16(last_vc_index - i);
> + break;
> + }
> +
> + /* Write VCE */
> + if (s390_cpu_virt_mem_write(cpu, addr + vcb_hdr->out_len, r1, vce,
> vce_len)) {
> + s390_cpu_virt_mem_handle_exc(cpu, ra);
> + g_free(vce);
... But using g_free() here.