linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mfd: dln2: Fix sanity checking for endpoints
@ 2020-02-26 14:51 Andy Shevchenko
  2020-03-12 17:07 ` Andy Shevchenko
  2020-03-13  6:58 ` Lee Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-02-26 14:51 UTC (permalink / raw)
  To: Lee Jones, linux-kernel
  Cc: Andy Shevchenko, Oliver Neukum, Greg Kroah-Hartman

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>
---
v2: Add enumerator (Lee)
 drivers/mfd/dln2.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
index 7841c11411d0..4faa8d2e5d04 100644
--- a/drivers/mfd/dln2.c
+++ b/drivers/mfd/dln2.c
@@ -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;
 
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mfd: dln2: Fix sanity checking for endpoints
  2020-02-26 14:51 [PATCH v2] mfd: dln2: Fix sanity checking for endpoints Andy Shevchenko
@ 2020-03-12 17:07 ` Andy Shevchenko
  2020-03-13  6:58 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-03-12 17:07 UTC (permalink / raw)
  To: Lee Jones, linux-kernel; +Cc: Oliver Neukum, Greg Kroah-Hartman

On Wed, Feb 26, 2020 at 04:51:58PM +0200, Andy Shevchenko wrote:
> 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?

> 
> 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>
> ---
> v2: Add enumerator (Lee)
>  drivers/mfd/dln2.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
> index 7841c11411d0..4faa8d2e5d04 100644
> --- a/drivers/mfd/dln2.c
> +++ b/drivers/mfd/dln2.c
> @@ -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;
>  
> -- 
> 2.25.0
> 

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mfd: dln2: Fix sanity checking for endpoints
  2020-02-26 14:51 [PATCH v2] mfd: dln2: Fix sanity checking for endpoints Andy Shevchenko
  2020-03-12 17:07 ` Andy Shevchenko
@ 2020-03-13  6:58 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2020-03-13  6:58 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, Oliver Neukum, Greg Kroah-Hartman

On Wed, 26 Feb 2020, Andy Shevchenko wrote:

> 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>
> ---
> v2: Add enumerator (Lee)
>  drivers/mfd/dln2.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Applied, thanks.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-13  6:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26 14:51 [PATCH v2] mfd: dln2: Fix sanity checking for endpoints Andy Shevchenko
2020-03-12 17:07 ` Andy Shevchenko
2020-03-13  6:58 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).