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

Commit 6b314d42 authored by Vladis Dronov's avatar Vladis Dronov Committed by Sasha Levin
Browse files

Input: gtco - fix crash on detecting device without endpoints

[ Upstream commit 162f98dea487206d9ab79fc12ed64700667a894d ]

The gtco driver expects at least one valid endpoint. If given malicious
descriptors that specify 0 for the number of endpoints, it will crash in
the probe function. Ensure there is at least one endpoint on the interface
before using it.

Also let's fix a minor coding style issue.

The full correct report of this issue can be found in the public
Red Hat Bugzilla:

https://bugzilla.redhat.com/show_bug.cgi?id=1283385



Reported-by: default avatarRalf Spenneberg <ralf@spenneberg.net>
Signed-off-by: default avatarVladis Dronov <vdronov@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 83412555
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -868,6 +868,14 @@ static int gtco_probe(struct usb_interface *usbinterface,
		goto err_free_buf;
	}

	/* Sanity check that a device has an endpoint */
	if (usbinterface->altsetting[0].desc.bNumEndpoints < 1) {
		dev_err(&usbinterface->dev,
			"Invalid number of endpoints\n");
		error = -EINVAL;
		goto err_free_urb;
	}

	/*
	 * The endpoint is always altsetting 0, we know this since we know
	 * this device only has one interrupt endpoint