diff options
author | Karel Zak | 2019-05-15 15:57:09 +0200 |
---|---|---|
committer | Karel Zak | 2019-05-15 15:57:09 +0200 |
commit | 8083862536df0635a66e147031e2061ddf4ac098 (patch) | |
tree | 12d5caef955309da318beb0a9c3eaadb814949c0 /lib | |
parent | lib/path: fix ul_path_get_dirfd() usage [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-8083862536df0635a66e147031e2061ddf4ac098.tar.gz kernel-qcow2-util-linux-8083862536df0635a66e147031e2061ddf4ac098.tar.xz kernel-qcow2-util-linux-8083862536df0635a66e147031e2061ddf4ac098.zip |
lib/path: fix possible NULL dereferencing [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/path.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/path.c b/lib/path.c index 9b05f4b98..6922e2770 100644 --- a/lib/path.c +++ b/lib/path.c @@ -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) */ |