Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17fa4adb authored by Arumuga Durai A's avatar Arumuga Durai A
Browse files

USB: android: Fix rmnet_gport_setup error path handling on sigkill



rmnet_gport_setup might fail if userspace killed adbd while
usb_add_config was executed in its context. This results in
alloc_workqueue failure followed by rmnet_gport_setup bailing
out. Next time when adbd is started, gport_setup doesnt happen
(due to rmnet_initialized) and rmnet bind_config fails. Fix
this by setting rmnet_initialized only when rmnet_gport_setup
is successful and also perform cleanup when gport_setup fails.

CRs-Fixed: 1021758
Change-Id: Ia0df36f734ba2e2ad54dec6e93d80593c4813447
Signed-off-by: default avatarArumuga Durai A <cadurai@codeaurora.org>
parent 0c3a23a4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -938,7 +938,6 @@ static int rmnet_function_bind_config(struct android_usb_function *f,
	static int rmnet_initialized, ports;

	if (!rmnet_initialized) {
		rmnet_initialized = 1;
		strlcpy(buf, rmnet_transports, sizeof(buf));
		b = strim(buf);

@@ -967,8 +966,11 @@ static int rmnet_function_bind_config(struct android_usb_function *f,
		err = rmnet_gport_setup();
		if (err) {
			pr_err("rmnet: Cannot setup transports");
			frmnet_deinit_port();
			ports = 0;
			goto out;
		}
		rmnet_initialized = 1;
	}

	for (i = 0; i < ports; i++) {
+17 −0
Original line number Diff line number Diff line
@@ -1471,3 +1471,20 @@ fail_probe:

	return ret;
}
static void frmnet_deinit_port(void)
{
	int i;

	for (i = 0; i < nr_rmnet_ports; i++)
		kfree(rmnet_ports[i].port);

	nr_rmnet_ports = 0;
	no_ctrl_smd_ports = 0;
	no_ctrl_qti_ports = 0;
	no_data_bam_ports = 0;
	no_data_bam2bam_ports = 0;
	no_ctrl_hsic_ports = 0;
	no_data_hsic_ports = 0;
	no_ctrl_hsuart_ports = 0;
	no_data_hsuart_ports = 0;
}