Skip to contentSkip to conversation

mfd: dln2: Fix sanity checking for endpoints

PATCH Applied Andy Shevchenko 2 participants 3 messages Feb 26, 2020 – Mar 13, 2020 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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 <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

---
v2: Add enumerator (Lee)

 drivers/mfd/dln2.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mfd/dln2.c +7 -2
index 7841c11411d0..4faa8d2e5d04 100644
@@ -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;
@@ -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;
 
Signature · 1 line
2.25.0
#1 lore raw
Quoted 9 lines · Andy Shevchenko

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.

Lee, is this now okay?

Quoted 42 lines
Fixes 2b8bd606b1e6 ("mfd: dln2: More sanity checking for endpoints")
Cc Oliver Neukum <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

---
v2: Add enumerator (Lee)

 drivers/mfd/dln2.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mfd/dln2.c +7 -2
index 7841c11411d0..4faa8d2e5d04 100644
@@ -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;
@@ -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;
 
Signature · 1 line
2.25.0
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Applied
#2 lore raw
In reply to Andy Shevchenko
Quoted 10 lines · Andy Shevchenko

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.

Quoted 8 lines
Fixes 2b8bd606b1e6 ("mfd: dln2: More sanity checking for endpoints")
Cc Oliver Neukum <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

---
v2: Add enumerator (Lee)

 drivers/mfd/dln2.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog