On Mon, 2 Mar 2020 12:13:52 +0200 "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote: > +static int set_vcpu_pid_mapping(struct guest *guest, int cpu, int pid) > +{ > + int *cpu_pid; > + int i; > + > + if (cpu >= guest->cpu_max) { > + cpu_pid = realloc(guest->cpu_pid, (cpu + 1) * sizeof(int)); > + if (!cpu_pid) > + return -1; > + /* Handle sparse CPU numbers */ > + for (i = guest->cpu_max; i < cpu; i++) > + guest->cpu_pid[i] = -1; That needs to be: cpu_pid[i] = -1; as realloc() may have freed guest->cpu_pid here. -- Steve > + guest->cpu_max = cpu + 1; > + guest->cpu_pid = cpu_pid; > + } > + guest->cpu_pid[cpu] = pid; > + return 0; > +}