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

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