All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] multipath-tools 0.12.0 - late minor fixes
@ 2025-09-05 21:07 Martin Wilck
  2025-09-05 21:07 ` [PATCH 1/2] libmultipath: fix missing return value check in snprint_devices() Martin Wilck
  2025-09-05 21:07 ` [PATCH 2/2] libmultipath/foreign/nvme: fix return value check in get_ctrl_blkdev() Martin Wilck
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Wilck @ 2025-09-05 21:07 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: Xose Vazquez Perez, dm-devel

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(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] libmultipath: fix missing return value check in snprint_devices()
  2025-09-05 21:07 [PATCH 0/2] multipath-tools 0.12.0 - late minor fixes Martin Wilck
@ 2025-09-05 21:07 ` Martin Wilck
  2025-09-08 18:34   ` Benjamin Marzinski
  2025-09-05 21:07 ` [PATCH 2/2] libmultipath/foreign/nvme: fix return value check in get_ctrl_blkdev() Martin Wilck
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Wilck @ 2025-09-05 21:07 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: Xose Vazquez Perez, dm-devel

Coverity scan defect #488155.

Fixes: d041258 ("libmultipath: snprint_devices(): use udev_enumerate")
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/print.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libmultipath/print.c b/libmultipath/print.c
index 019ae56..a7306f0 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -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;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] libmultipath/foreign/nvme: fix return value check in get_ctrl_blkdev()
  2025-09-05 21:07 [PATCH 0/2] multipath-tools 0.12.0 - late minor fixes Martin Wilck
  2025-09-05 21:07 ` [PATCH 1/2] libmultipath: fix missing return value check in snprint_devices() Martin Wilck
@ 2025-09-05 21:07 ` Martin Wilck
  2025-09-08 18:54   ` Benjamin Marzinski
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Wilck @ 2025-09-05 21:07 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: Xose Vazquez Perez, dm-devel

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 <mwilck@suse.com>
---
 libmultipath/foreign/nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libmultipath/foreign/nvme.c b/libmultipath/foreign/nvme.c
index 0d19303..4cbdf60 100644
--- a/libmultipath/foreign/nvme.c
+++ b/libmultipath/foreign/nvme.c
@@ -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) {
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] libmultipath: fix missing return value check in snprint_devices()
  2025-09-05 21:07 ` [PATCH 1/2] libmultipath: fix missing return value check in snprint_devices() Martin Wilck
@ 2025-09-08 18:34   ` Benjamin Marzinski
  2025-09-09  8:57     ` Martin Wilck
  0 siblings, 1 reply; 6+ messages in thread
From: Benjamin Marzinski @ 2025-09-08 18:34 UTC (permalink / raw)
  To: Martin Wilck; +Cc: Christophe Varoqui, Xose Vazquez Perez, dm-devel

On Fri, Sep 05, 2025 at 11:07:13PM +0200, Martin Wilck wrote:
> 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:

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>

> Fixes: d041258 ("libmultipath: snprint_devices(): use udev_enumerate")
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  libmultipath/print.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libmultipath/print.c b/libmultipath/print.c
> index 019ae56..a7306f0 100644
> --- a/libmultipath/print.c
> +++ b/libmultipath/print.c
> @@ -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;
> -- 
> 2.51.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] libmultipath/foreign/nvme: fix return value check in get_ctrl_blkdev()
  2025-09-05 21:07 ` [PATCH 2/2] libmultipath/foreign/nvme: fix return value check in get_ctrl_blkdev() Martin Wilck
@ 2025-09-08 18:54   ` Benjamin Marzinski
  0 siblings, 0 replies; 6+ messages in thread
From: Benjamin Marzinski @ 2025-09-08 18:54 UTC (permalink / raw)
  To: Martin Wilck; +Cc: Christophe Varoqui, Xose Vazquez Perez, dm-devel

On Fri, Sep 05, 2025 at 11:07:14PM +0200, Martin Wilck wrote:
> 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 <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
>  libmultipath/foreign/nvme.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libmultipath/foreign/nvme.c b/libmultipath/foreign/nvme.c
> index 0d19303..4cbdf60 100644
> --- a/libmultipath/foreign/nvme.c
> +++ b/libmultipath/foreign/nvme.c
> @@ -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) {
> -- 
> 2.51.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] libmultipath: fix missing return value check in snprint_devices()
  2025-09-08 18:34   ` Benjamin Marzinski
@ 2025-09-09  8:57     ` Martin Wilck
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Wilck @ 2025-09-09  8:57 UTC (permalink / raw)
  To: Benjamin Marzinski; +Cc: Christophe Varoqui, Xose Vazquez Perez, dm-devel

On Mon, 2025-09-08 at 14:34 -0400, Benjamin Marzinski wrote:
> On Fri, Sep 05, 2025 at 11:07:13PM +0200, Martin Wilck wrote:
> > 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:

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

Martin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-09-09  8:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-05 21:07 [PATCH 0/2] multipath-tools 0.12.0 - late minor fixes Martin Wilck
2025-09-05 21:07 ` [PATCH 1/2] libmultipath: fix missing return value check in snprint_devices() Martin Wilck
2025-09-08 18:34   ` Benjamin Marzinski
2025-09-09  8:57     ` Martin Wilck
2025-09-05 21:07 ` [PATCH 2/2] libmultipath/foreign/nvme: fix return value check in get_ctrl_blkdev() Martin Wilck
2025-09-08 18:54   ` Benjamin Marzinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.