Coverity has trouble tracking data flow sometimes, and believes that
sysfs_readlink() and read_sysfs_file() will sometimes return >= 0 when
the buffer has not been filled out. This changes the check to also test
for a NULL pointer, hopefully pacifying it.
Signed-off-by: Peter Jones <pjones@redhat.com>
tmp[devpart - current] = '\0';
rc = sysfs_readlink(&linkbuf, "class/block/%s/driver", tmp);
free(tmp);
- if (rc < 0) {
+ if (rc < 0 || !linkbuf) {
efi_error("Could not find driver for pci device");
return -1;
}
if (dev->part == -1) {
rc = read_sysfs_file(&tmpbuf, "dev/block/%s/partition", dev->link);
- if (rc < 0) {
+ if (rc < 0 || !tmpbuf) {
efi_error("device has no /partition node; not a partition");
} else {
rc = sscanf((char *)tmpbuf, "%d\n", &dev->part);