On Wed, Aug 12, 2020 at 01:35:58PM +0200, mwilck@xxxxxxxx wrote: > From: Martin Wilck <mwilck@xxxxxxxx> > > 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@xxxxxxxxxx> > Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> > --- > 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 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel