Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1564257 > unrolled thread

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

Started by"Maciej S. Szmigiero" <mail@maciej.szmigiero.name>
First post2017-01-22 00:00 +0100
Last post2017-01-22 00:00 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] w1: don't leak refcount on slave attach failure in  w1_attach_slave_device() "Maciej S. Szmigiero" <mail@maciej.szmigiero.name> - 2017-01-22 00:00 +0100

#1564257 — [PATCH] w1: don't leak refcount on slave attach failure in w1_attach_slave_device()

From"Maciej S. Szmigiero" <mail@maciej.szmigiero.name>
Date2017-01-22 00:00 +0100
Subject[PATCH] w1: don't leak refcount on slave attach failure in w1_attach_slave_device()
Message-ID<t2cNA-1aI-13@gated-at.bofh.it>
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: 9fcbbac5ded489 ("w1: process w1 netlink commands in w1_process thread")
---
 drivers/w1/w1.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index e213c678bbfe..ab0931e7a9bb 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -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;
 	}

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web