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

Commit aab232f3 authored by Mayank Rana's avatar Mayank Rana
Browse files

usb: gadget: u_ether: Add NULL check for link->in_ep and link->out_ep



gether_connect() API checks link->in_ep and link->out_ep against NULL
but missing as part of error handling. Below are possible NULL pointer
dereference situations:

1. If there is no link->in_ep endpoint and enabling of link->out_ep
fails, link->in_ep endpoint is accessed without checking it against NULL
as part of error handling.

2. If alloc_requests() returns non-zero value (i.e. result variable
becomes non-zero), then both link->in_ep and link->out_ep endpoints are
accessed without checking it against NULL.

Fix above issues by adding NULL check against link->in_ep and link->out_ep
endpoints.

CRs-Fixed: 1056034
Change-Id: Icaa9d12a6414b895984e874ddeb12992e622fb56
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent d5fa91ad
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2131,8 +2131,10 @@ struct net_device *gether_connect(struct gether *link)

	/* on error, disable any endpoints  */
	} else {
		if (link->out_ep)
			(void) usb_ep_disable(link->out_ep);
fail1:
		if (link->in_ep)
			(void) usb_ep_disable(link->in_ep);
	}