mirror of
https://github.com/torvalds/linux.git
synced 2026-11-25 16:02:57 +00:00
mfd: dln2: More sanity checking for endpoints
It is not enough to check for the number of endpoints. The types must also be correct. Reported-and-tested-by: [email protected] Signed-off-by: Oliver Neukum <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Lee Jones <[email protected]>
This commit is contained in:
+11
-2
@@ -722,6 +722,8 @@ static int dln2_probe(struct usb_interface *interface,
|
||||
const struct usb_device_id *usb_id)
|
||||
{
|
||||
struct usb_host_interface *hostif = interface->cur_altsetting;
|
||||
struct usb_endpoint_descriptor *epin;
|
||||
struct usb_endpoint_descriptor *epout;
|
||||
struct device *dev = &interface->dev;
|
||||
struct dln2_dev *dln2;
|
||||
int ret;
|
||||
@@ -731,12 +733,19 @@ static int dln2_probe(struct usb_interface *interface,
|
||||
hostif->desc.bNumEndpoints < 2)
|
||||
return -ENODEV;
|
||||
|
||||
epin = &hostif->endpoint[0].desc;
|
||||
epout = &hostif->endpoint[1].desc;
|
||||
if (!usb_endpoint_is_bulk_out(epout))
|
||||
return -ENODEV;
|
||||
if (!usb_endpoint_is_bulk_in(epin))
|
||||
return -ENODEV;
|
||||
|
||||
dln2 = kzalloc(sizeof(*dln2), GFP_KERNEL);
|
||||
if (!dln2)
|
||||
return -ENOMEM;
|
||||
|
||||
dln2->ep_out = hostif->endpoint[0].desc.bEndpointAddress;
|
||||
dln2->ep_in = hostif->endpoint[1].desc.bEndpointAddress;
|
||||
dln2->ep_out = epout->bEndpointAddress;
|
||||
dln2->ep_in = epin->bEndpointAddress;
|
||||
dln2->usb_dev = usb_get_dev(interface_to_usbdev(interface));
|
||||
dln2->interface = interface;
|
||||
usb_set_intfdata(interface, dln2);
|
||||
|
||||
Reference in New Issue
Block a user