Skip to content

Commit

Permalink
Input: ims-pcu - validate number of endpoints before using them
Browse files Browse the repository at this point in the history
Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer should a malicious device lack control-interface endpoints.

Fixes: 628329d ("Input: add IMS Passenger Control Unit driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
Cc: stable@vger.kernel.org	# 3.10
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
  • Loading branch information
Johan Hovold authored and Dmitry Torokhov committed Mar 16, 2017
1 parent ac2ee9b commit 1916d31
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/input/misc/ims-pcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,10 @@ static int ims_pcu_parse_cdc_data(struct usb_interface *intf, struct ims_pcu *pc
return -EINVAL;

alt = pcu->ctrl_intf->cur_altsetting;

if (alt->desc.bNumEndpoints < 1)
return -ENODEV;

pcu->ep_ctrl = &alt->endpoint[0].desc;
pcu->max_ctrl_size = usb_endpoint_maxp(pcu->ep_ctrl);

Expand Down

0 comments on commit 1916d31

Please sign in to comment.