提交 877a202f 编写于 作者: A Aditya Pakki 提交者: Greg Kroah-Hartman

thunderbolt: Fix to check return value of ida_simple_get

[ Upstream commit 9aabb68568b473bf2f0b179d053b403961e42e4d ]

In enumerate_services, ida_simple_get on failure can return an error and
leaks memory. The patch ensures that the dev_set_name is set on non
failure cases, and releases memory during failure.
Signed-off-by: NAditya Pakki <pakki001@umn.edu>
Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
上级 b9291078
...@@ -743,6 +743,7 @@ static void enumerate_services(struct tb_xdomain *xd) ...@@ -743,6 +743,7 @@ static void enumerate_services(struct tb_xdomain *xd)
struct tb_service *svc; struct tb_service *svc;
struct tb_property *p; struct tb_property *p;
struct device *dev; struct device *dev;
int id;
/* /*
* First remove all services that are not available anymore in * First remove all services that are not available anymore in
...@@ -771,7 +772,12 @@ static void enumerate_services(struct tb_xdomain *xd) ...@@ -771,7 +772,12 @@ static void enumerate_services(struct tb_xdomain *xd)
break; break;
} }
svc->id = ida_simple_get(&xd->service_ids, 0, 0, GFP_KERNEL); id = ida_simple_get(&xd->service_ids, 0, 0, GFP_KERNEL);
if (id < 0) {
kfree(svc);
break;
}
svc->id = id;
svc->dev.bus = &tb_bus_type; svc->dev.bus = &tb_bus_type;
svc->dev.type = &tb_service_type; svc->dev.type = &tb_service_type;
svc->dev.parent = &xd->dev; svc->dev.parent = &xd->dev;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册