[dm-devel] [PATCH v2 81/84] multipath: check_path_valid(): eliminate some failure modes
Benjamin Marzinski
bmarzins at redhat.com
Mon Aug 17 21:56:11 UTC 2020
On Wed, Aug 12, 2020 at 01:35:58PM +0200, mwilck at suse.com wrote:
> From: Martin Wilck <mwilck at suse.com>
>
> The memory allocations can fail, and pathvec is not needed until the
> path_discovery() call. Eliminate the failure modes by not setting up
> pathvec before it's actually needed.
>
Reviewed-by: Benjamin Marzinski <bmarzins at redhat.com>
> Signed-off-by: Martin Wilck <mwilck at suse.com>
> ---
> multipath/main.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/multipath/main.c b/multipath/main.c
> index 9d6b482..9e65070 100644
> --- a/multipath/main.c
> +++ b/multipath/main.c
> @@ -637,15 +637,6 @@ check_path_valid(const char *name, struct config *conf, bool is_uevent)
> minor(devt));
> }
>
> - pathvec = vector_alloc();
> - if (!pathvec)
> - goto fail;
> -
> - if (store_path(pathvec, pp) != 0) {
> - free_path(pp);
> - goto fail;
> - }
> -
> if ((r == PATH_IS_VALID || r == PATH_IS_MAYBE_VALID) &&
> released_to_systemd())
> r = PATH_IS_NOT_VALID;
> @@ -684,6 +675,15 @@ check_path_valid(const char *name, struct config *conf, bool is_uevent)
> goto out;
> }
>
> + pathvec = vector_alloc();
> + if (!pathvec)
> + goto fail;
> +
> + if (store_path(pathvec, pp) != 0) {
> + free_path(pp);
> + goto fail;
> + }
> +
> /* For find_multipaths = SMART, if there is more than one path
> * matching the refwwid, then the path is valid */
> if (path_discovery(pathvec, DI_SYSFS | DI_WWID) < 0)
> --
> 2.28.0
More information about the dm-devel
mailing list