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

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