Skip to content

Commit

Permalink
mfd: dln2: Fix sanity checking for endpoints
Browse files Browse the repository at this point in the history
[ Upstream commit fb945c9 ]

While the commit 2b8bd60 ("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: 2b8bd60 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Andy Shevchenko authored and Greg Kroah-Hartman committed Apr 17, 2020
1 parent 98666f2 commit e176f1d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/mfd/dln2.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ struct dln2_mod_rx_slots {
spinlock_t lock;
};

enum dln2_endpoint {
DLN2_EP_OUT = 0,
DLN2_EP_IN = 1,
};

struct dln2_dev {
struct usb_device *usb_dev;
struct usb_interface *interface;
Expand Down Expand Up @@ -733,10 +738,10 @@ static int dln2_probe(struct usb_interface *interface,
hostif->desc.bNumEndpoints < 2)
return -ENODEV;

epin = &hostif->endpoint[0].desc;
epout = &hostif->endpoint[1].desc;
epout = &hostif->endpoint[DLN2_EP_OUT].desc;
if (!usb_endpoint_is_bulk_out(epout))
return -ENODEV;
epin = &hostif->endpoint[DLN2_EP_IN].desc;
if (!usb_endpoint_is_bulk_in(epin))
return -ENODEV;

Expand Down

0 comments on commit e176f1d

Please sign in to comment.