util: netdev: Dynamically allocate 'struct nlattr' in virNetDevSwitchdevFeature

At time of writing DEVLINK_ATTR_MAX equals to 176, thus the stack'd size
of the pointer array is almost 1.4kiB. Allocate it dynamically.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-09-05 16:22:47 +02:00
parent 9a3110862f
commit 89c7ff156b

View File

@ -3210,7 +3210,7 @@ virNetDevSwitchdevFeature(const char *ifname,
struct nl_msg *nl_msg = NULL;
g_autofree struct nlmsghdr *resp = NULL;
unsigned int recvbuflen;
struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {NULL, };
g_autofree struct nlattr **tb = g_new0(struct nlattr *, DEVLINK_ATTR_MAX + 1);
g_autoptr(virPCIDevice) pci_device_ptr = NULL;
struct genlmsghdr gmsgh = {
.cmd = DEVLINK_CMD_ESWITCH_GET,