static void * get_next_ucode(int cpu, const u8 *buf, unsigned int size, unsigned int *mc_size) { unsigned int actual_size = 0; u8 section_hdr[UCODE_CONTAINER_SECTION_HDR]; void *mc = NULL; if (get_ucode_data(section_hdr, buf, UCODE_CONTAINER_SECTION_HDR)) return NULL; if (section_hdr[0] != UCODE_UCODE_TYPE) { printk(KERN_ERR "microcode: error: invalid type field in " "container file section header\n"); return NULL; } actual_size = verify_ucode_size(cpu, buf, size); if (!actual_size) return NULL; mc = vmalloc(actual_size); if (!mc) return NULL; memset(mc, 0, actual_size); get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR, actual_size); *mc_size = actual_size + UCODE_CONTAINER_SECTION_HDR; return mc; }
static struct microcode_header_amd * get_next_ucode(int cpu, const u8 *buf, unsigned int size, unsigned int *mc_size) { struct microcode_header_amd *mc = NULL; unsigned int actual_size = 0; if (*(u32 *)buf != UCODE_UCODE_TYPE) { pr_err("invalid type field in container file section header\n"); goto out; } actual_size = verify_ucode_size(cpu, buf, size); if (!actual_size) goto out; mc = vzalloc(actual_size); if (!mc) goto out; get_ucode_data(mc, buf + SECTION_HDR_SIZE, actual_size); *mc_size = actual_size + SECTION_HDR_SIZE; out: return mc; }