2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00

plugins/amdgpu - Increase maximum parameter length

The topology parsing assumed that all parameter names were
30 characters or fewer, but

recommended_sdma_engine_id_mask

is 31 characters.

Make the maximum length a macro, and set it to 64.

Signed-off-by: David Francis <David.Francis@amd.com>
This commit is contained in:
David Francis 2024-09-16 09:43:12 -04:00 committed by Andrei Vagin
parent 60ee5ebd9d
commit 096c1f7a4d

View File

@ -20,6 +20,7 @@
#include "amdgpu_plugin_topology.h"
#define TOPOLOGY_PATH "/sys/class/kfd/kfd/topology/nodes/"
#define MAX_PARAMETER_LEN 64
/* User override options */
/* Skip firmware version check */
@ -417,7 +418,9 @@ struct tp_node *sys_add_node(struct tp_system *sys, uint32_t id, uint32_t gpu_id
static bool get_prop(char *line, char *name, uint64_t *value)
{
if (sscanf(line, " %29s %lu", name, value) != 2)
char format[16];
sprintf(format, " %%%ds %%lu", MAX_PARAMETER_LEN);
if (sscanf(line, format, name, value) != 2)
return false;
return true;
}
@ -437,7 +440,7 @@ static int parse_topo_node_properties(struct tp_node *dev, const char *dir_path)
}
while (fgets(line, sizeof(line), file)) {
char name[30];
char name[MAX_PARAMETER_LEN + 1];
uint64_t value;
memset(name, 0, sizeof(name));
@ -565,7 +568,7 @@ static int parse_topo_node_mem_banks(struct tp_node *node, const char *dir_path)
}
while (fgets(line, sizeof(line), file)) {
char name[30];
char name[MAX_PARAMETER_LEN + 1];
uint64_t value;
memset(name, 0, sizeof(name));
@ -654,7 +657,7 @@ static int parse_topo_node_iolinks(struct tp_node *node, const char *dir_path)
}
while (fgets(line, sizeof(line), file)) {
char name[30];
char name[MAX_PARAMETER_LEN + 1];
uint64_t value;
memset(name, 0, sizeof(name));