aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuman Anna <s-anna@ti.com>2017-05-09 19:58:24 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-16 17:06:41 -0400
commit0d83539092ddb1ab79b4d65bccb866bf07ea2ccd (patch)
treef0b3168108e1c6afbb51982bcd8099a9265f1cce
parenta20cfc1cde76047657045fc5976834f57422a8c5 (diff)
uio: fix incorrect memory leak cleanup
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/uio/uio.c8
1 files 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)
279 map = kzalloc(sizeof(*map), GFP_KERNEL); 279 map = kzalloc(sizeof(*map), GFP_KERNEL);
280 if (!map) { 280 if (!map) {
281 ret = -ENOMEM; 281 ret = -ENOMEM;
282 goto err_map_kobj; 282 goto err_map;
283 } 283 }
284 kobject_init(&map->kobj, &map_attr_type); 284 kobject_init(&map->kobj, &map_attr_type);
285 map->mem = mem; 285 map->mem = mem;
@@ -289,7 +289,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
289 goto err_map_kobj; 289 goto err_map_kobj;
290 ret = kobject_uevent(&map->kobj, KOBJ_ADD); 290 ret = kobject_uevent(&map->kobj, KOBJ_ADD);
291 if (ret) 291 if (ret)
292 goto err_map; 292 goto err_map_kobj;
293 } 293 }
294 294
295 for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) { 295 for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) {
@@ -308,7 +308,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
308 portio = kzalloc(sizeof(*portio), GFP_KERNEL); 308 portio = kzalloc(sizeof(*portio), GFP_KERNEL);
309 if (!portio) { 309 if (!portio) {
310 ret = -ENOMEM; 310 ret = -ENOMEM;
311 goto err_portio_kobj; 311 goto err_portio;
312 } 312 }
313 kobject_init(&portio->kobj, &portio_attr_type); 313 kobject_init(&portio->kobj, &portio_attr_type);
314 portio->port = port; 314 portio->port = port;
@@ -319,7 +319,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
319 goto err_portio_kobj; 319 goto err_portio_kobj;
320 ret = kobject_uevent(&portio->kobj, KOBJ_ADD); 320 ret = kobject_uevent(&portio->kobj, KOBJ_ADD);
321 if (ret) 321 if (ret)
322 goto err_portio; 322 goto err_portio_kobj;
323 } 323 }
324 324
325 return 0; 325 return 0;