Skip to contentSkip to conversation

thunderbolt: Fix memory leak if ida_simple_get() fails in enumerate_services()

PATCH In review Mika Westerberg 1 participant 4 messages Oct 29, 2020 – Nov 5, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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")
---
 drivers/thunderbolt/xdomain.c | 1 +
 1 file changed, 1 insertion(+)
drivers/thunderbolt/xdomain.c +1 -0
index 48907853732a..c00ad817042e 100644
@@ -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;
 		}
Signature · 1 line
2.28.0
#1 lore raw

PATCH 2/3 thunderbolt: Add uaccess dependency to debugfs interface

From: Casey Bowman <[email protected]>

Some calls in the debugfs interface are made to the linux/uaccess.h header, but the header is not referenced. So, for x86_64 architectures, this dependency seems to be pulled in elsewhere, which leads to a successful compilation. However, on arm/arm64 architectures, it was found to error out on implicit declarations.

This change fixes the implicit declaration error by adding the linux/uaccess.h header.

Fixes 54e418106c76 ("thunderbolt: Add debugfs interface")
---
 drivers/thunderbolt/debugfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/thunderbolt/debugfs.c +1 -0
index 3680b2784ea1..ed65d2b13964 100644
@@ -9,6 +9,7 @@
 
 #include <linux/debugfs.h>
 #include <linux/pm_runtime.h>
+#include <linux/uaccess.h>
 
 #include "tb.h"
 
Signature · 1 line
2.28.0
#2 lore raw

PATCH 3/3 thunderbolt: Only configure USB4 wake for lane 0 adapters

In reply to Mika Westerberg

Only USB4 lane 0 adapter has the USB4 port capability for wakes so only program wakes on such adapters.

Fixes b2911a593a70 ("thunderbolt: Enable wakes from system suspend")
---
 drivers/thunderbolt/usb4.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/thunderbolt/usb4.c +4 -0
index 40f13579a3fe..f2583b4053e4 100644
@@ -421,8 +421,12 @@ int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags)
 	 * upstream USB4 port.
 	 */
 	tb_switch_for_each_port(sw, port) {
+		if (!tb_port_is_null(port))
+			continue;
 		if (!route && tb_is_upstream_port(port))
 			continue;
+		if (!port->cap_usb4)
+			continue;
 
 		ret = tb_port_read(port, &val, TB_CFG_PORT,
 				   port->cap_usb4 + PORT_CS_19, 1);
Signature · 1 line
2.28.0