Skip to content

Commit

Permalink
w1: don't leak refcount on slave attach failure in w1_attach_slave_de…
Browse files Browse the repository at this point in the history
…vice()

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: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Cc: stable@vger.kernel.org
Fixes: 9fcbbac ("w1: process w1 netlink commands in w1_process thread")
Cc: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Maciej S. Szmigiero authored and Greg Kroah-Hartman committed Jan 25, 2017
1 parent dd6478d commit d2ce4ea
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/w1/w1.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,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;
}
Expand Down

0 comments on commit d2ce4ea

Please sign in to comment.