Skip to contentSkip to conversation

multipath-tools 0.12.0 - late minor fixes

PATCH In review Martin Wilck 2 participants 6 messages Sep 5, 2025 – Sep 9, 2025 Device mapper

lore
Share & tools
lore
#0 lore raw

cover multipath-tools 0.12.0 - late minor fixes

Two minor fixes that resulted from a coverity scan.

Martin Wilck (2):
libmultipath: fix missing return value check in snprint_devices() libmultipath/foreign/nvme: fix return value check in get_ctrl_blkdev()

 libmultipath/foreign/nvme.c | 2 +-
 libmultipath/print.c        | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/2 libmultipath: fix missing return value check in snprint_devices()

Coverity scan defect #488155.

Fixes d041258 ("libmultipath: snprint_devices(): use udev_enumerate")
---
 libmultipath/print.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libmultipath/print.c +2 -1
index 019ae56..a7306f0 100644
@@ -1993,7 +1993,8 @@ int snprint_devices(struct config *conf, struct strbuf *buff,
 	enm = udev_enumerate_new(udev);
 	if (!enm)
 		return 1;
-	udev_enumerate_add_match_subsystem(enm, "block");
+	if ((r = udev_enumerate_add_match_subsystem(enm, "block")) < 0)
+		goto out;
 
 	if ((r = append_strbuf_str(buff, "available block devices:\n")) < 0)
 		goto out;
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] libmultipath: fix missing return value check in snprint_devices()

Quoted 2 lines · Martin Wilck

Coverity scan defect #488155.

Your fix looks fine, but the code I see right above it isn't. We should not be returning a positive number here if things went wrong. Looking at the udev_enumerate_new() code, we should be safe always trusting it to set errno correctly. So, the code should probably be

if (!enm)

	return -errno; 

If you don't want to handle that is this commit then:

Quoted 22 lines
Fixes d041258 ("libmultipath: snprint_devices(): use udev_enumerate")
---
 libmultipath/print.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libmultipath/print.c +2 -1
index 019ae56..a7306f0 100644
@@ -1993,7 +1993,8 @@ int snprint_devices(struct config *conf, struct strbuf *buff,
 	enm = udev_enumerate_new(udev);
 	if (!enm)
 		return 1;
-	udev_enumerate_add_match_subsystem(enm, "block");
+	if ((r = udev_enumerate_add_match_subsystem(enm, "block")) < 0)
+		goto out;
 
 	if ((r = append_strbuf_str(buff, "available block devices:\n")) < 0)
 		goto out;
Signature · 1 line
2.51.0
#3 lore raw

Re: [PATCH 1/2] libmultipath: fix missing return value check in snprint_devices()

Quoted 11 lines · Benjamin Marzinski
Quoted 2 lines · Martin Wilck

Coverity scan defect #488155.

Your fix looks fine, but the code I see right above it isn't. We should
not be returning a positive number here if things went wrong. Looking at the udev_enumerate_new() code, we should be safe always trusting it to
set errno correctly. So, the code should probably be

Quoted 4 lines

if (!enm)

	return -errno; 

If you don't want to handle that is this commit then:

Right. I'll push another fix on top, using your suggestion. Thanks for spotting it!

Martin

#4 lore raw

PATCH 2/2 libmultipath/foreign/nvme: fix return value check in get_ctrl_blkdev()

In reply to Martin Wilck

Only a negative return value from udev_enumerate_add_match_subsystem() indicates an error.

Fixes 7b47762 ("libmultipath: nvme: fix path detection for kernel 4.16")
---
 libmultipath/foreign/nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/foreign/nvme.c +1 -1
index 0d19303..4cbdf60 100644
@@ -536,7 +536,7 @@ struct udev_device *get_ctrl_blkdev(const struct context *ctx,
 	pthread_cleanup_push(_udev_enumerate_unref, enm);
 	if (udev_enumerate_add_match_parent(enm, ctrl) < 0)
 		goto out;
-	if (udev_enumerate_add_match_subsystem(enm, "block"))
+	if (udev_enumerate_add_match_subsystem(enm, "block") < 0)
 		goto out;
 
 	if (udev_enumerate_scan_devices(enm) < 0) {
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] libmultipath/foreign/nvme: fix return value check in get_ctrl_blkdev()

Quoted 6 lines · Martin Wilck

Only a negative return value from udev_enumerate_add_match_subsystem() indicates an error.

Fixes 7b47762 ("libmultipath: nvme: fix path detection for kernel 4.16")
Quoted 19 lines
---
 libmultipath/foreign/nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/foreign/nvme.c +1 -1
index 0d19303..4cbdf60 100644
@@ -536,7 +536,7 @@ struct udev_device *get_ctrl_blkdev(const struct context *ctx,
 	pthread_cleanup_push(_udev_enumerate_unref, enm);
 	if (udev_enumerate_add_match_parent(enm, ctrl) < 0)
 		goto out;
-	if (udev_enumerate_add_match_subsystem(enm, "block"))
+	if (udev_enumerate_add_match_subsystem(enm, "block") < 0)
 		goto out;
 
 	if (udev_enumerate_scan_devices(enm) < 0) {
Signature · 1 line
2.51.0