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 <[email protected]>
> 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(-)
>
> 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