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