From: Karel Zak Date: Wed, 15 May 2019 13:57:09 +0000 (+0200) Subject: lib/path: fix possible NULL dereferencing [coverity scan] X-Git-Tag: v2.34-rc2~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8083862536df0635a66e147031e2061ddf4ac098;p=thirdparty%2Futil-linux.git lib/path: fix possible NULL dereferencing [coverity scan] Signed-off-by: Karel Zak --- diff --git a/lib/path.c b/lib/path.c index 9b05f4b98a..6922e27704 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) */