thunderbolt: Fix memory leak if ida_simple_get() fails in enumerate_services()
authorMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 7 Oct 2020 14:06:17 +0000 (17:06 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Thu, 5 Nov 2020 10:32:40 +0000 (13:32 +0300)
The svc->key field is not released as it should be if ida_simple_get()
fails so fix that.

Fixes: 9aabb68568b4 ("thunderbolt: Fix to check return value of ida_simple_get")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/xdomain.c

index 4890785..c00ad81 100644 (file)
@@ -881,6 +881,7 @@ static void enumerate_services(struct tb_xdomain *xd)
 
                id = ida_simple_get(&xd->service_ids, 0, 0, GFP_KERNEL);
                if (id < 0) {
+                       kfree(svc->key);
                        kfree(svc);
                        break;
                }