Commit de143f74 authored by Maciej S. Szmigiero's avatar Maciej S. Szmigiero Committed by Sasha Levin

w1: don't leak refcount on slave attach failure in w1_attach_slave_device()

[ Upstream commit d2ce4ea1 ]

Near the beginning of w1_attach_slave_device() we increment a w1 master
reference count.
Later, when we are going to exit this function without actually attaching
a slave device (due to failure of __w1_attach_slave_device()) we need to
decrement this reference count back.
Signed-off-by: default avatarMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Cc: stable@vger.kernel.org
Fixes: 9fcbbac5 ("w1: process w1 netlink commands in w1_process thread")
Cc: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
parent 271ce503
......@@ -749,6 +749,7 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
dev_err(&dev->dev, "%s: Attaching %s failed.\n", __func__,
sl->name);
w1_family_put(sl->family);
atomic_dec(&sl->master->refcnt);
kfree(sl);
return err;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment