Commit 6c4538cf authored by Suman Anna's avatar Suman Anna Committed by Ben Hutchings

uio: fix incorrect memory leak cleanup

commit 0d835390 upstream.

Commit 75f0aef6 ("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: 75f0aef6 ("uio: fix memory leak")
Signed-off-by: default avatarSuman Anna <s-anna@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 128866ed
...@@ -291,7 +291,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) ...@@ -291,7 +291,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
map = kzalloc(sizeof(*map), GFP_KERNEL); map = kzalloc(sizeof(*map), GFP_KERNEL);
if (!map) { if (!map) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_map_kobj; goto err_map;
} }
kobject_init(&map->kobj, &map_attr_type); kobject_init(&map->kobj, &map_attr_type);
map->mem = mem; map->mem = mem;
...@@ -301,7 +301,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) ...@@ -301,7 +301,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
goto err_map_kobj; goto err_map_kobj;
ret = kobject_uevent(&map->kobj, KOBJ_ADD); ret = kobject_uevent(&map->kobj, KOBJ_ADD);
if (ret) if (ret)
goto err_map; goto err_map_kobj;
} }
for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) { for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) {
...@@ -320,7 +320,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) ...@@ -320,7 +320,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
portio = kzalloc(sizeof(*portio), GFP_KERNEL); portio = kzalloc(sizeof(*portio), GFP_KERNEL);
if (!portio) { if (!portio) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_portio_kobj; goto err_portio;
} }
kobject_init(&portio->kobj, &portio_attr_type); kobject_init(&portio->kobj, &portio_attr_type);
portio->port = port; portio->port = port;
...@@ -331,7 +331,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) ...@@ -331,7 +331,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
goto err_portio_kobj; goto err_portio_kobj;
ret = kobject_uevent(&portio->kobj, KOBJ_ADD); ret = kobject_uevent(&portio->kobj, KOBJ_ADD);
if (ret) if (ret)
goto err_portio; goto err_portio_kobj;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment