Blob Blame History Raw
From 72b55405a6f80807beee4dde71a4c25deb666ba8 Mon Sep 17 00:00:00 2001
Message-Id: <72b55405a6f80807beee4dde71a4c25deb666ba8@dist-git>
From: Laine Stump <laine@laine.org>
Date: Thu, 13 Apr 2017 14:29:19 -0400
Subject: [PATCH] util: permit querying a VF MAC address or VLAN tag by itself

virNetDevParseVfConfig() assumed that both the MAC address and VLAN
tag pointers were valid, so even if you only wanted one or the other,
you would need a variable to hold the returned value for both. This
patch checks each for a NULL pointer before filling it in.

Resolves: https://bugzilla.redhat.com/1442040 (RHEL 7.3.z)
Resolves: https://bugzilla.redhat.com/1415609 (RHEL 7.4)

(cherry picked from commit 176229dd05a6c96dec2b7b1c2fb0143d7331b10e)
---
 src/util/virnetdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index d12324878..75f969ded 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1534,7 +1534,7 @@ virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
             goto cleanup;
         }
 
-        if (tb[IFLA_VF_MAC]) {
+        if (mac && tb[IFLA_VF_MAC]) {
             vf_mac = RTA_DATA(tb_vf[IFLA_VF_MAC]);
             if (vf_mac && vf_mac->vf == vf)  {
                 virMacAddrSetRaw(mac, vf_mac->mac);
@@ -1542,7 +1542,7 @@ virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
             }
         }
 
-        if (tb[IFLA_VF_VLAN]) {
+        if (vlanid && tb[IFLA_VF_VLAN]) {
             vf_vlan = RTA_DATA(tb_vf[IFLA_VF_VLAN]);
             if (vf_vlan && vf_vlan->vf == vf)  {
                 *vlanid = vf_vlan->vlan;
-- 
2.12.2