lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1386962557-8899-5-git-send-email-levex@linux.com>
Date:	Fri, 13 Dec 2013 20:22:37 +0100
From:	Levente Kurusa <levex@...ux.com>
To:	LKML <linux-kernel@...r.kernel.org>
Cc:	Levente Kurusa <levex@...ux.com>,
	Evgeniy Polyakov <zbr@...emap.net>
Subject: [PATCH 4/4] w1: call put_device if device_register fails

Currently, memsetting and kfreeing the device is bad behaviour.
The device will have a reference count of 1 and hence can cause trouble
because it has kfree'd. Proper way to handle a failed device_register
is to call put_device right after it fails.

Signed-off-by: Levente Kurusa <levex@...ux.com>
---
 drivers/w1/w1_int.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 5a98649..0b9b59e 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -90,9 +90,8 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
 	err = device_register(&dev->dev);
 	if (err) {
 		printk(KERN_ERR "Failed to register master device. err=%d\n", err);
-		memset(dev, 0, sizeof(struct w1_master));
-		kfree(dev);
-		dev = NULL;
+		put_device(&dev->dev);
+		return NULL;
 	}
 
 	return dev;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ