Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: dln2: Fix sanity checking for endpoints

While the commit 2b8bd606b1e6 ("mfd: dln2: More sanity checking for endpoints")
tries to harden the sanity checks it made at the same time a regression,
i.e. mixed in and out endpoints. Obviously it should have been not tested on
real hardware at that time, but unluckily it didn't happen.

So, fix above mentioned typo and make device being enumerated again.

While here, introduce an enumerator for magic values to prevent similar issue
to happen in the future.

Fixes: 2b8bd606b1e6 ("mfd: dln2: More sanity checking for endpoints")
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Andy Shevchenko and committed by
Lee Jones
fb945c95 4e213b45

+7 -2
+7 -2
drivers/mfd/dln2.c
··· 90 90 spinlock_t lock; 91 91 }; 92 92 93 + enum dln2_endpoint { 94 + DLN2_EP_OUT = 0, 95 + DLN2_EP_IN = 1, 96 + }; 97 + 93 98 struct dln2_dev { 94 99 struct usb_device *usb_dev; 95 100 struct usb_interface *interface; ··· 738 733 hostif->desc.bNumEndpoints < 2) 739 734 return -ENODEV; 740 735 741 - epin = &hostif->endpoint[0].desc; 742 - epout = &hostif->endpoint[1].desc; 736 + epout = &hostif->endpoint[DLN2_EP_OUT].desc; 743 737 if (!usb_endpoint_is_bulk_out(epout)) 744 738 return -ENODEV; 739 + epin = &hostif->endpoint[DLN2_EP_IN].desc; 745 740 if (!usb_endpoint_is_bulk_in(epin)) 746 741 return -ENODEV; 747 742