[PATCH v3] arm64: Add purgatory printing

Matthias Brugger mbrugger at suse.com
Wed Sep 30 14:04:57 EDT 2020



On 30/09/2020 17:20, Geoff Levand wrote:
> Hi,
> 
> On 9/30/20 3:36 AM, matthias.bgg at kernel.org wrote:
>> --- a/kexec/arch/arm64/include/arch/options.h
>> +++ b/kexec/arch/arm64/include/arch/options.h
>>
>> +static uint64_t find_purgatory_sink(const char *console)
>> +{
>> +	int fd, ret;
>> +	char device[255], mem[255];
>> +	struct stat sb;
>> +	char buffer[10];
>> +	uint64_t iomem = 0x0;
>> +
>> +	if (!console)
>> +		return 0;
>> +
>> +	ret = snprintf(device, sizeof(device), "/sys/class/tty/%s", console);
>> +	if (ret < 0 || ret >= sizeof(device)) {
>> +		fprintf(stderr, "snprintf failed: %s\n", strerror(errno));
>> +		return 0;
>> +	}
>> +
>> +	if (stat(device, &sb) || !S_ISDIR(sb.st_mode)) {
>> +		fprintf(stderr, "kexec: %s: No valid console found for %s\n",
>> +			__func__, device);
>> +		return 0;
>> +	}
>> +
>> +	snprintf(mem, sizeof(mem), "%s%s", device, "/iomem_base");
>> +	if (ret < 0 || ret >= sizeof(mem)) {
> 
> Seems this is is just doing the same check again...
> 

Well we have to check snprintf outcome here again. Also sizeof(device) == 
sizeof(mem) we could have the case where the first snprintf fits into the 255 
character, while the second, where we add the "/iomem_base" does not.

Or didn't I understand you correctly?

Regards,
Matthias



More information about the kexec mailing list