From 8083862536df0635a66e147031e2061ddf4ac098 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 15 May 2019 15:57:09 +0200 Subject: lib/path: fix possible NULL dereferencing [coverity scan] Signed-off-by: Karel Zak --- lib/path.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') 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) */ -- cgit v1.2.3-55-g7522