lib/path: fix possible NULL dereferencing [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-05-15 15:57:09 +02:00
parent 8e28151329
commit 8083862536
1 changed files with 4 additions and 2 deletions

View File

@ -570,10 +570,12 @@ int ul_path_read_string(struct path_cxt *pc, char **str, const char *path)
char buf[BUFSIZ];
int rc;
*str = NULL;
if (!str)
return -EINVAL;
*str = NULL;
rc = ul_path_read(pc, buf, sizeof(buf) - 1, path);
if (rc < 0 || !str)
if (rc < 0)
return rc;
/* Remove tailing newline (usual in sysfs) */