diff mbox series

iforce: add sanity checks

Message ID 20190806141538.8121-2-oneukum@suse.com (mailing list archive)
State Accepted
Commit 849f5ae3a513c550cad741c68dd3d7eb2bcc2a2c
Headers show
Series iforce: add sanity checks | expand

Commit Message

Oliver Neukum Aug. 6, 2019, 2:15 p.m. UTC
The endpoint type should also be checked before a device
is accepted.

Reported-by: syzbot+5efc10c005014d061a74@syzkaller.appspotmail.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/input/joystick/iforce/iforce-usb.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Dmitry Torokhov Aug. 6, 2019, 4:10 p.m. UTC | #1
On Tue, Aug 06, 2019 at 04:15:38PM +0200, Oliver Neukum wrote:
> The endpoint type should also be checked before a device
> is accepted.
> 
> Reported-by: syzbot+5efc10c005014d061a74@syzkaller.appspotmail.com
> Signed-off-by: Oliver Neukum <oneukum@suse.com>

Moved the checks to where the assignments are and applied. Thank you
Oliver.

BTW, could you please CC me on the stuff in drivers/input/...

Thanks!

> ---
>  drivers/input/joystick/iforce/iforce-usb.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
> index 29abfeeef9a5..a481a226166c 100644
> --- a/drivers/input/joystick/iforce/iforce-usb.c
> +++ b/drivers/input/joystick/iforce/iforce-usb.c
> @@ -203,6 +203,11 @@ static int iforce_usb_probe(struct usb_interface *intf,
>  	epirq = &interface->endpoint[0].desc;
>  	epout = &interface->endpoint[1].desc;
>  
> +	if (!usb_endpoint_is_int_in(epirq))
> +		return -ENODEV;
> +	if (!usb_endpoint_is_int_out(epout))
> +		return -ENODEV;
> +
>  	iforce_usb = kzalloc(sizeof(*iforce_usb), GFP_KERNEL);
>  	if (!iforce_usb)
>  		goto fail;
> -- 
> 2.16.4
>
diff mbox series

Patch

diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index 29abfeeef9a5..a481a226166c 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -203,6 +203,11 @@  static int iforce_usb_probe(struct usb_interface *intf,
 	epirq = &interface->endpoint[0].desc;
 	epout = &interface->endpoint[1].desc;
 
+	if (!usb_endpoint_is_int_in(epirq))
+		return -ENODEV;
+	if (!usb_endpoint_is_int_out(epout))
+		return -ENODEV;
+
 	iforce_usb = kzalloc(sizeof(*iforce_usb), GFP_KERNEL);
 	if (!iforce_usb)
 		goto fail;