Blob Blame History Raw
From 9bd2624ad05dc1a78a094d48f78e7a8a07deec24 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 11 Jul 2016 15:57:28 -0400
Subject: [PATCH 207/261] efinet: fix some coverity gripes.

Related: rhbz#1154226

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 grub-core/net/bootp.c              |  9 +++++----
 grub-core/net/drivers/efi/efinet.c | 11 +++++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
index 4793ebc43..46ce8135a 100644
--- a/grub-core/net/bootp.c
+++ b/grub-core/net/bootp.c
@@ -349,10 +349,11 @@ grub_net_configure_by_dhcpv6_ack (const char *name,
   struct grub_net_network_level_address addr;
   int mask = -1;
 
-  if (device)
-    *device = 0;
-  if (path)
-    *path = 0;
+  if (!device || !path)
+    return NULL;
+
+  *device = 0;
+  *path = 0;
 
   grub_dprintf ("net", "mac address is %02x:%02x:%02x:%02x:%02x:%02x\n",
 		hwaddr->mac[0], hwaddr->mac[1], hwaddr->mac[2],
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index ed103df7a..2244f1403 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -401,6 +401,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
     if (pxe_mode->using_ipv6)
       {
 	grub_net_link_level_address_t hwaddr;
+	struct grub_net_network_level_interface *intf;
 
 	grub_dprintf ("efinet", "using ipv6 and dhcpv6\n");
 	grub_dprintf ("efinet", "dhcp_ack_received: %s%s\n",
@@ -414,10 +415,12 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
 		     card->efi_net->mode->current_address,
 		     sizeof (hwaddr.mac));
 
-	grub_net_configure_by_dhcpv6_ack (card->name, card, 0,
-					  &hwaddr, &pxe_mode->dhcp_ack.dhcpv6,
-					  1, device, path);
-	grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
+	intf = grub_net_configure_by_dhcpv6_ack (card->name, card, 0,
+						 &hwaddr,
+						 &pxe_mode->dhcp_ack.dhcpv6,
+						 1, device, path);
+	if (intf && device && path)
+	  grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
       }
     else
       {
-- 
2.13.5