Blame SOURCES/0004-Pacify-some-coverity-nits.patch

80b73c
From bd609a59369574c95f7f31b15caae8bb86b71f39 Mon Sep 17 00:00:00 2001
80b73c
From: Peter Jones <pjones@redhat.com>
80b73c
Date: Tue, 12 Jun 2018 14:36:20 -0400
80b73c
Subject: [PATCH 04/17] Pacify some coverity nits.
80b73c
80b73c
Coverity has trouble tracking data flow sometimes, and believes that
80b73c
sysfs_readlink() and read_sysfs_file() will sometimes return >= 0 when
80b73c
the buffer has not been filled out.  This changes the check to also test
80b73c
for a NULL pointer, hopefully pacifying it.
80b73c
80b73c
Signed-off-by: Peter Jones <pjones@redhat.com>
80b73c
---
80b73c
 src/linux-pci.c | 2 +-
80b73c
 src/linux.c     | 2 +-
80b73c
 2 files changed, 2 insertions(+), 2 deletions(-)
80b73c
80b73c
diff --git a/src/linux-pci.c b/src/linux-pci.c
80b73c
index 87878c39c94..0d2a90ab166 100644
80b73c
--- a/src/linux-pci.c
80b73c
+++ b/src/linux-pci.c
80b73c
@@ -166,7 +166,7 @@ parse_pci(struct device *dev, const char *current)
80b73c
                 tmp[devpart - current] = '\0';
80b73c
                 rc = sysfs_readlink(&linkbuf, "class/block/%s/driver", tmp);
80b73c
                 free(tmp);
80b73c
-                if (rc < 0) {
80b73c
+                if (rc < 0 || !linkbuf) {
80b73c
                         efi_error("Could not find driver for pci device");
80b73c
                         return -1;
80b73c
                 }
80b73c
diff --git a/src/linux.c b/src/linux.c
80b73c
index c8d1b3a9285..fe45c6004b9 100644
80b73c
--- a/src/linux.c
80b73c
+++ b/src/linux.c
80b73c
@@ -356,7 +356,7 @@ struct device HIDDEN
80b73c
 
80b73c
         if (dev->part == -1) {
80b73c
                 rc = read_sysfs_file(&tmpbuf, "dev/block/%s/partition", dev->link);
80b73c
-                if (rc < 0) {
80b73c
+                if (rc < 0 || !tmpbuf) {
80b73c
                         efi_error("device has no /partition node; not a partition");
80b73c
                 } else {
80b73c
                         rc = sscanf((char *)tmpbuf, "%d\n", &dev->part);
80b73c
-- 
80b73c
2.17.1
80b73c