multipath-tools 0.12.0 - late minor fixes
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
PATCH 1/2 libmultipath: fix missing return value check in snprint_devices()
Coverity scan defect #488155.
--- libmultipath/print.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
libmultipath/print.c +2 -1
@@ -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
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")Signed-off-by Martin Wilck <[email protected]>--- libmultipath/print.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)libmultipath/print.c +2
-1@@ -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
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 theudev_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
PATCH 2/2 libmultipath/foreign/nvme: fix return value check in get_ctrl_blkdev()
In reply to Martin WilckOnly a negative return value from udev_enumerate_add_match_subsystem() indicates an error.
--- libmultipath/foreign/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/foreign/nvme.c +1 -1
@@ -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
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")Signed-off-by Martin Wilck <[email protected]>
Quoted 19 lines
--- libmultipath/foreign/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libmultipath/foreign/nvme.c +1
-1@@ -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