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


Groups > linux.kernel > #1638459

[PATCH] uio: fix incorrect memory leak cleanup

Path csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod
From Suman Anna <s-anna@ti.com>
Newsgroups linux.kernel
Subject [PATCH] uio: fix incorrect memory leak cleanup
Date Wed, 10 May 2017 02:00:02 +0200
Message-ID <tFncS-lu-3@gated-at.bofh.it> (permalink)
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1494374314; bh=YNTQUoVn7vpjyI8XjiiY6mP6lTsou9Dk0lqXjhhAMb0=; h=From:To:CC:Subject:Date; b=H2ZvtdfheuNMyyTcXz/UbA+IusNsSiYQqYzHvWm8GDM4k/Ruvq1WEXqZCWb37UVW5 tD1UhUGUUIDk7d8vtKgJNECDzsn+NW6zTwz4W2S54igJcOEO9iq3fz/EYI83cOLAom PKlAsZUtXh0HorVj5CcyxYrnr1jsfYk3veB22I2o=
X-Mailer git-send-email 2.12.0
MIME-Version 1.0
Content-Type text/plain
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 55
Organization linux.* mail to news gateway
X-Original-Cc <linux-kernel@vger.kernel.org>, Suman Anna <s-anna@ti.com>
X-Original-Date Tue, 9 May 2017 18:58:24 -0500
X-Original-Message-ID <20170509235824.43458-1-s-anna@ti.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1638459

Show key headers only | View raw


Commit 75f0aef6220d ("uio: fix memory leak") has fixed up some
memory leaks during the failure paths of the addition of uio
attributes, but still is not correct entirely. A kobject_uevent()
failure still needs a kobject_put() and the kobject container
structure allocation failure before the kobject_init() doesn't
need a kobject_put(). Fix this properly.

Fixes: 75f0aef6220d ("uio: fix memory leak")
Signed-off-by: Suman Anna <s-anna@ti.com>
---
 drivers/uio/uio.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 1c196f87e9d9..ff04b7f8549f 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -279,7 +279,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
 		map = kzalloc(sizeof(*map), GFP_KERNEL);
 		if (!map) {
 			ret = -ENOMEM;
-			goto err_map_kobj;
+			goto err_map;
 		}
 		kobject_init(&map->kobj, &map_attr_type);
 		map->mem = mem;
@@ -289,7 +289,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
 			goto err_map_kobj;
 		ret = kobject_uevent(&map->kobj, KOBJ_ADD);
 		if (ret)
-			goto err_map;
+			goto err_map_kobj;
 	}
 
 	for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) {
@@ -308,7 +308,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
 		portio = kzalloc(sizeof(*portio), GFP_KERNEL);
 		if (!portio) {
 			ret = -ENOMEM;
-			goto err_portio_kobj;
+			goto err_portio;
 		}
 		kobject_init(&portio->kobj, &portio_attr_type);
 		portio->port = port;
@@ -319,7 +319,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
 			goto err_portio_kobj;
 		ret = kobject_uevent(&portio->kobj, KOBJ_ADD);
 		if (ret)
-			goto err_portio;
+			goto err_portio_kobj;
 	}
 
 	return 0;
-- 
2.12.0

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] uio: fix incorrect memory leak cleanup Suman Anna <s-anna@ti.com> - 2017-05-10 02:00 +0200

csiph-web