]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.53/w1-don-t-leak-refcount-on-slave-attach-failure-in-w1_attach_slave_device.patch
Linux 3.18.140
[thirdparty/kernel/stable-queue.git] / releases / 4.4.53 / w1-don-t-leak-refcount-on-slave-attach-failure-in-w1_attach_slave_device.patch
1 From d2ce4ea1a0b0162e5d2d7e7942ab6f5cc2063d5a Mon Sep 17 00:00:00 2001
2 From: "Maciej S. Szmigiero" <mail@maciej.szmigiero.name>
3 Date: Sat, 21 Jan 2017 23:50:18 +0100
4 Subject: w1: don't leak refcount on slave attach failure in w1_attach_slave_device()
5
6 From: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
7
8 commit d2ce4ea1a0b0162e5d2d7e7942ab6f5cc2063d5a upstream.
9
10 Near the beginning of w1_attach_slave_device() we increment a w1 master
11 reference count.
12 Later, when we are going to exit this function without actually attaching
13 a slave device (due to failure of __w1_attach_slave_device()) we need to
14 decrement this reference count back.
15
16 Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
17 Fixes: 9fcbbac5ded489 ("w1: process w1 netlink commands in w1_process thread")
18 Cc: Evgeniy Polyakov <zbr@ioremap.net>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21 ---
22 drivers/w1/w1.c | 1 +
23 1 file changed, 1 insertion(+)
24
25 --- a/drivers/w1/w1.c
26 +++ b/drivers/w1/w1.c
27 @@ -763,6 +763,7 @@ int w1_attach_slave_device(struct w1_mas
28 dev_err(&dev->dev, "%s: Attaching %s failed.\n", __func__,
29 sl->name);
30 w1_family_put(sl->family);
31 + atomic_dec(&sl->master->refcnt);
32 kfree(sl);
33 return err;
34 }