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

Commit f7df4abf authored by Krishna Kurapati's avatar Krishna Kurapati Committed by Gerrit - the friendly Code Review server
Browse files

usb: gadget: gsi: Avoid accessing an uninitialized variable



Prevent dereferencing an uninitialized f_gsi pointer.
Return a valid gsi context only after finding a valid
gsi_opts instance. Else return NULL.

Change-Id: I75578c0bc3f4673ec66cb80bcb7a6ae328489253
Signed-off-by: default avatarKrishna Kurapati <kriskura@codeaurora.org>
parent 1ca91eb8
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -207,12 +207,12 @@ static struct f_gsi *get_connected_gsi(void)
	int i;

	for (i = 0; i < IPA_USB_MAX_TETH_PROT_SIZE; i++) {
		if (inst_status[i].opts)
		if (inst_status[i].opts) {
			connected_gsi = inst_status[i].opts->gsi;

			if (connected_gsi && atomic_read(&connected_gsi->connected))
				return connected_gsi;
		}
	}

	return NULL;
}