diff mbox series

[1/3] thunderbolt: Fix memory leak if ida_simple_get() fails in enumerate_services()

Message ID 20201029094636.51818-1-mika.westerberg@linux.intel.com (mailing list archive)
State Accepted
Commit a663e0df4a374b8537562a44d1cecafb472cd65b
Headers show
Series [1/3] thunderbolt: Fix memory leak if ida_simple_get() fails in enumerate_services() | expand

Commit Message

Mika Westerberg Oct. 29, 2020, 9:46 a.m. UTC
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 | 1 +
 1 file changed, 1 insertion(+)

Comments

Mika Westerberg Nov. 5, 2020, 10:37 a.m. UTC | #1
On Thu, Oct 29, 2020 at 12:46:34PM +0300, Mika Westerberg wrote:
> 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>

This and the other 2 patches applied to thunderbolt.git/fixes.
diff mbox series

Patch

diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index 48907853732a..c00ad817042e 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -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;
 		}