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-next>] [day] [month] [year] [list]
Message-id: <00c701d07e33$acbca360$0635ea20$@samsung.com>
Date:	Fri, 24 Apr 2015 10:08:43 +0800
From:	Chao Yu <chao2.yu@...sung.com>
To:	axboe@...nel.dk
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] elevator: fix memory leak in ->elevator_init_fn

In ->elevator_init_fn, if we fail to call kzalloc_node, we should release
elevator queue space which is allocated previously, otherwise it will cause
memory leak.

Signed-off-by: Chao Yu <chao2.yu@...sung.com>
---
 block/cfq-iosched.c      | 1 +
 block/deadline-iosched.c | 1 +
 block/noop-iosched.c     | 1 +
 3 files changed, 3 insertions(+)

diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 5da8e6e..2793fb7 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -4391,6 +4391,7 @@ static int cfq_init_queue(struct request_queue *q, struct elevator_type *e)
 	cfqd = kzalloc_node(sizeof(*cfqd), GFP_KERNEL, q->node);
 	if (!cfqd) {
 		kobject_put(&eq->kobj);
+		kfree(eq);
 		return -ENOMEM;
 	}
 	eq->elevator_data = cfqd;
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index a753df2..bc6d7d9 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -349,6 +349,7 @@ static int deadline_init_queue(struct request_queue *q, struct elevator_type *e)
 	dd = kzalloc_node(sizeof(*dd), GFP_KERNEL, q->node);
 	if (!dd) {
 		kobject_put(&eq->kobj);
+		kfree(eq);
 		return -ENOMEM;
 	}
 	eq->elevator_data = dd;
diff --git a/block/noop-iosched.c b/block/noop-iosched.c
index 3de89d4..1399c78 100644
--- a/block/noop-iosched.c
+++ b/block/noop-iosched.c
@@ -71,6 +71,7 @@ static int noop_init_queue(struct request_queue *q, struct elevator_type *e)
 	nd = kmalloc_node(sizeof(*nd), GFP_KERNEL, q->node);
 	if (!nd) {
 		kobject_put(&eq->kobj);
+		kfree(eq);
 		return -ENOMEM;
 	}
 	eq->elevator_data = nd;
-- 
2.3.3


--
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