From: Milan Broz <mbroz@redhat.com> Date: Sat, 16 Aug 2008 01:51:51 +0200 Subject: [md] dm mpath: fix bugs in error paths Message-id: 48A61697.7080206@redhat.com O-Subject: [RHEL5.3 PATCH] dm mpath: fix bugs in error paths (#459092) Bugzilla: 459092 RH-Acked-by: Alasdair G Kergon <agk@redhat.com> RH-Acked-by: Alasdair G Kergon <agk@redhat.com> RHEL5.3 dm mpath: fix several problems in dm-mpath target error paths Resolves: rhbz#459092 Patches are upstream, commits def052d21c4e77975bb75cf212f018ec913f8e2f 148acff615b403168cdf39e55bfcfaa6e4a7d233 371b2e348b7731a548b0a7432ca2ba32e90dd16f These are trivial bugfixes in multipath dm target: - Fix test for reinstate_path method before attempting to use it. - Return a specific error message if there are an invalid number of multipath arguments. - Free path selector if the arguments are invalid. Kernel with patch compiled and tested. diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 679bc96..2412c5a 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -524,8 +524,10 @@ static int parse_path_selector(struct arg_set *as, struct priority_group *pg, } r = read_param(_params, shift(as), &ps_argc, &ti->error); - if (r) + if (r) { + dm_put_path_selector(pst); return -EINVAL; + } r = pst->create(&pg->ps, ps_argc, as->argv); if (r) { @@ -622,8 +624,10 @@ static struct priority_group *parse_priority_group(struct arg_set *as, struct pgpath *pgpath; struct arg_set path_args; - if (as->argc < nr_params) + if (as->argc < nr_params) { + ti->error = "not enough path parameters"; goto bad; + } path_args.argc = nr_params; path_args.argv = as->argv; @@ -881,7 +885,7 @@ static int reinstate_path(struct pgpath *pgpath) if (pgpath->path.is_active) goto out; - if (!pgpath->pg->ps.type) { + if (!pgpath->pg->ps.type->reinstate_path) { DMWARN("Reinstate path not supported by path selector %s", pgpath->pg->ps.type->name); r = -EINVAL;