[lvm-devel] main - cov: check strchr for NULL

Zdenek Kabelac zkabelac at sourceware.org
Tue Sep 21 19:51:05 UTC 2021


Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7bd55f8c152041101a27c83a96b794fdbb366460
Commit:        7bd55f8c152041101a27c83a96b794fdbb366460
Parent:        377e326156c74ef7aa7f5ac286bdabe3143a0b49
Author:        Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate:    Tue Sep 21 18:24:30 2021 +0200
Committer:     Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Tue Sep 21 21:03:47 2021 +0200

cov: check strchr for NULL

Although unlikely, ensuring coverity we not use NULL.
---
 daemons/lvmlockd/lvmlockd-dlm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/daemons/lvmlockd/lvmlockd-dlm.c b/daemons/lvmlockd/lvmlockd-dlm.c
index 68d18607c..1305c3dc2 100644
--- a/daemons/lvmlockd/lvmlockd-dlm.c
+++ b/daemons/lvmlockd/lvmlockd-dlm.c
@@ -801,7 +801,8 @@ int lm_refresh_lv_start_dlm(struct action *act)
 	strncpy(path, act->path, PATH_MAX-1);
 
 	/* skip past dev */
-	p = strchr(path + 1, '/');
+	if (!(p = strchr(path + 1, '/')))
+		return -EINVAL;
 
 	/* skip past slashes */
 	while (*p == '/')




More information about the lvm-devel mailing list