Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dm mpath: Add missing dm_put_device when failing to get scsi dh name

When commit fd81bc5cca8f ("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: fd81bc5cca8f ("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>

authored by

Benjamin Marzinski and committed by
Mikulas Patocka
787bd63e ec853402

+10 -10
+10 -10
drivers/md/dm-mpath.c
··· 960 960 attached_handler_name = NULL; 961 961 } else { 962 962 r = PTR_ERR(attached_handler_name); 963 - goto bad; 963 + ti->error = "error allocating handler name"; 964 + goto bad_put_device; 964 965 } 965 966 } 966 967 if (attached_handler_name || m->hw_handler_name) { 967 968 INIT_DELAYED_WORK(&p->activate_path, activate_path_work); 968 969 r = setup_scsi_dh(p->path.dev->bdev, m, &attached_handler_name, &ti->error); 969 970 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; 974 973 } 975 974 976 975 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; 981 978 982 979 return p; 983 - bad: 980 + 981 + bad_put_device: 982 + dm_put_device(ti, p->path.dev); 983 + bad: 984 984 free_pgpath(p); 985 985 return ERR_PTR(r); 986 986 }