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

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