]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.19/dm-mpath-always-free-attached_handler_name-in-parse_path.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 5.0.19 / dm-mpath-always-free-attached_handler_name-in-parse_path.patch
1 From 940bc471780b004a5277c1931f52af363c2fc9da Mon Sep 17 00:00:00 2001
2 From: Martin Wilck <mwilck@suse.com>
3 Date: Mon, 29 Apr 2019 11:48:15 +0200
4 Subject: dm mpath: always free attached_handler_name in parse_path()
5
6 From: Martin Wilck <mwilck@suse.com>
7
8 commit 940bc471780b004a5277c1931f52af363c2fc9da upstream.
9
10 Commit b592211c33f7 ("dm mpath: fix attached_handler_name leak and
11 dangling hw_handler_name pointer") fixed a memory leak for the case
12 where setup_scsi_dh() returns failure. But setup_scsi_dh may return
13 success and not "use" attached_handler_name if the
14 retain_attached_hwhandler flag is not set on the map. As setup_scsi_sh
15 properly "steals" the pointer by nullifying it, freeing it
16 unconditionally in parse_path() is safe.
17
18 Fixes: b592211c33f7 ("dm mpath: fix attached_handler_name leak and dangling hw_handler_name pointer")
19 Cc: stable@vger.kernel.org
20 Reported-by: Yufen Yu <yuyufen@huawei.com>
21 Signed-off-by: Martin Wilck <mwilck@suse.com>
22 Signed-off-by: Mike Snitzer <snitzer@redhat.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25 ---
26 drivers/md/dm-mpath.c | 2 +-
27 1 file changed, 1 insertion(+), 1 deletion(-)
28
29 --- a/drivers/md/dm-mpath.c
30 +++ b/drivers/md/dm-mpath.c
31 @@ -882,6 +882,7 @@ static struct pgpath *parse_path(struct
32 if (attached_handler_name || m->hw_handler_name) {
33 INIT_DELAYED_WORK(&p->activate_path, activate_path_work);
34 r = setup_scsi_dh(p->path.dev->bdev, m, &attached_handler_name, &ti->error);
35 + kfree(attached_handler_name);
36 if (r) {
37 dm_put_device(ti, p->path.dev);
38 goto bad;
39 @@ -896,7 +897,6 @@ static struct pgpath *parse_path(struct
40
41 return p;
42 bad:
43 - kfree(attached_handler_name);
44 free_pgpath(p);
45 return ERR_PTR(r);
46 }