]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
w1: fix redundant counter decrement in w1_attach_slave_device()
authorHaoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Thu, 18 Dec 2025 11:14:14 +0000 (19:14 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Jan 2026 09:27:34 +0000 (10:27 +0100)
commit cc8f92e41eb76f450f05234fef2054afc3633100 upstream.

In w1_attach_slave_device(), if __w1_attach_slave_device() fails,
put_device() -> w1_slave_release() is called to do the cleanup job.
In w1_slave_release(), sl->family->refcnt and sl->master->slave_count
have already been decremented. There is no need to decrement twice
in w1_attach_slave_device().

Fixes: 2c927c0c73fd ("w1: Fix slave count on 1-Wire bus (resend)")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Link: https://patch.msgid.link/20251218111414.564403-1-lihaoxiang@isrc.iscas.ac.cn
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/w1/w1.c

index 5353cbd75126c120f4f202038be16c3e27fdef63..570c1ff780fcfd49119a90626c25a6d44755b8f8 100644 (file)
@@ -758,8 +758,6 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
        if (err < 0) {
                dev_err(&dev->dev, "%s: Attaching %s failed.\n", __func__,
                         sl->name);
-               dev->slave_count--;
-               w1_family_put(sl->family);
                atomic_dec(&sl->master->refcnt);
                kfree(sl);
                return err;