Re: [PATCH v21 01/13] trace-cmd: Find and store pids of tasks, which run virtual CPUs of given VM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
> +}



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux