diff options
author | Aditya Pakki <pakki001@umn.edu> | 2019-03-20 11:34:09 -0500 |
---|---|---|
committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2019-03-22 13:26:01 +0300 |
commit | 9aabb68568b473bf2f0b179d053b403961e42e4d (patch) | |
tree | 8dc07888afcc3d562ab9eabb4b02a3d694c8c2e7 /drivers/thunderbolt/xdomain.c | |
parent | 2cc12751cf464a722ff57b54d17d30c84553f9c0 (diff) |
thunderbolt: Fix to check return value of ida_simple_get
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: Aditya Pakki <pakki001@umn.edu>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt/xdomain.c')
-rw-r--r-- | drivers/thunderbolt/xdomain.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c index e27dd8beb94b..e0642dcb8b9b 100644 --- a/drivers/thunderbolt/xdomain.c +++ b/drivers/thunderbolt/xdomain.c @@ -740,6 +740,7 @@ static void enumerate_services(struct tb_xdomain *xd) struct tb_service *svc; struct tb_property *p; struct device *dev; + int id; /* * First remove all services that are not available anymore in @@ -768,7 +769,12 @@ static void enumerate_services(struct tb_xdomain *xd) 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.type = &tb_service_type; svc->dev.parent = &xd->dev; |