Skip to content

Commit 787bd63

Browse files
bmarzinsMikulas Patocka
authored andcommitted
dm mpath: Add missing dm_put_device when failing to get scsi dh name
When commit fd81bc5 ("scsi: device_handler: Return error pointer in scsi_dh_attached_handler_name()") added code to fail parsing the path if scsi_dh_attached_handler_name() failed with -ENOMEM, it didn't clean up the reference to the path device that had just been taken. Fix this, and steamline the error paths of parse_path() a little. Fixes: fd81bc5 ("scsi: device_handler: Return error pointer in scsi_dh_attached_handler_name()") Cc: stable@vger.kernel.org Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
1 parent ec85340 commit 787bd63

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

drivers/md/dm-mpath.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -960,27 +960,27 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
960960
attached_handler_name = NULL;
961961
} else {
962962
r = PTR_ERR(attached_handler_name);
963-
goto bad;
963+
ti->error = "error allocating handler name";
964+
goto bad_put_device;
964965
}
965966
}
966967
if (attached_handler_name || m->hw_handler_name) {
967968
INIT_DELAYED_WORK(&p->activate_path, activate_path_work);
968969
r = setup_scsi_dh(p->path.dev->bdev, m, &attached_handler_name, &ti->error);
969970
kfree(attached_handler_name);
970-
if (r) {
971-
dm_put_device(ti, p->path.dev);
972-
goto bad;
973-
}
971+
if (r)
972+
goto bad_put_device;
974973
}
975974

976975
r = ps->type->add_path(ps, &p->path, as->argc, as->argv, &ti->error);
977-
if (r) {
978-
dm_put_device(ti, p->path.dev);
979-
goto bad;
980-
}
976+
if (r)
977+
goto bad_put_device;
981978

982979
return p;
983-
bad:
980+
981+
bad_put_device:
982+
dm_put_device(ti, p->path.dev);
983+
bad:
984984
free_pgpath(p);
985985
return ERR_PTR(r);
986986
}

0 commit comments

Comments
 (0)