linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop
@ 2022-03-06 17:50 Jakob Koschel
  2022-03-06 17:50 ` [PATCH 01/26] usb: gadget: fsl: remove usage of list iterator past the loop body Jakob Koschel
                   ` (25 more replies)
  0 siblings, 26 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

ok, let's start here.

This patch set removes any use of the list iterator variable past
the list body. This will allow defining the list iterator variable
within the list_for_each_entry_*() macros to avoid any (invalid)
use after the loop. If no break/goto was hit during list traversal
the list iterator variable would otherwise be a bogus pointer
since it is computed on something that is not actually an element
of the list.

I've basically followed what we discussed in:
https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/

There are some cases where it might be possible to 'ditch' the tmp
variable and refactor the code past the loop into the loop body.
For the sake of keeping the *_dequeue() functions more similar, I've
decided against doing it for some and leaving it in others.

In general there are four use cases after the loop body here:

1) using &req->req in a comparision after the loop
2) using the iterator as a pointer in a comparision after the loop
3) use the &iterator->list to compare with the head to see if the
	loop exits early
4) using the iterator past the loop but using the rc variable to see if the
	loop exits early

Jakob Koschel (26):
  usb: gadget: fsl: remove usage of list iterator past the loop body
  usb: gadget: bdc: remove usage of list iterator past the loop body
  usb: gadget: udc: atmel: remove usage of list iterator past the loop
    body
  usb: gadget: udc: pxa25x: remove usage of list iterator past the loop
    body
  usb: gadget: udc: at91: remove usage of list iterator past the loop
    body
  usb: gadget: goku_udc: remove usage of list iterator past the loop
    body
  usb: gadget: udc: gr_udc: remove usage of list iterator past the loop
    body
  usb: gadget: lpc32xx_udc: remove usage of list iterator past the loop
    body
  usb: gadget: mv_u3d: remove usage of list iterator past the loop body
  usb: gadget: udc: mv_udc_core: remove usage of list iterator past the
    loop body
  usb: gadget: net2272: remove usage of list iterator past the loop body
  usb: gadget: udc: net2280: remove usage of list iterator past the loop
    body
  usb: gadget: omap_udc: remove usage of list iterator past the loop
    body
  usb: gadget: s3c-hsudc: remove usage of list iterator past the loop
    body
  usb: gadget: udc-xilinx: remove usage of list iterator past the loop
    body
  usb: gadget: aspeed: remove usage of list iterator past the loop body
  usb: gadget: configfs: remove using list iterator after loop body as a
    ptr
  usb: gadget: legacy: remove using list iterator after loop body as a
    ptr
  usb: gadget: udc: max3420_udc: remove using list iterator after loop
    body as a ptr
  usb: gadget: tegra-xudc: remove using list iterator after loop body as
    a ptr
  usb: gadget: composite: remove check of list iterator against head
    past the loop body
  usb: gadget: pxa27x_udc: replace usage of rc to check if a list
    element was found
  usb: gadget: udc: s3c2410: replace usage of rc to check if a list
    element was found
  usb: gadget: udc: core: replace usage of rc to check if a list element
    was found
  usb: gadget: dummy_hcd: replace usage of rc to check if a list element
    was found
  usb: gadget: udc: s3c2410: replace usage of rc to check if a list
    element was found

 drivers/usb/gadget/composite.c           | 18 ++++++++++--------
 drivers/usb/gadget/configfs.c            | 20 ++++++++++++--------
 drivers/usb/gadget/legacy/hid.c          | 23 ++++++++++++-----------
 drivers/usb/gadget/udc/aspeed-vhub/epn.c | 10 ++++++----
 drivers/usb/gadget/udc/at91_udc.c        | 10 ++++++----
 drivers/usb/gadget/udc/atmel_usba_udc.c  | 11 +++++++----
 drivers/usb/gadget/udc/bdc/bdc_ep.c      | 11 ++++++++---
 drivers/usb/gadget/udc/core.c            | 16 ++++++++++------
 drivers/usb/gadget/udc/dummy_hcd.c       | 11 ++++++-----
 drivers/usb/gadget/udc/fsl_qe_udc.c      | 11 +++++++----
 drivers/usb/gadget/udc/fsl_udc_core.c    | 11 +++++++----
 drivers/usb/gadget/udc/goku_udc.c        | 10 ++++++----
 drivers/usb/gadget/udc/gr_udc.c          | 10 ++++++----
 drivers/usb/gadget/udc/lpc32xx_udc.c     | 10 ++++++----
 drivers/usb/gadget/udc/max3420_udc.c     | 11 +++++++----
 drivers/usb/gadget/udc/mv_u3d_core.c     | 10 ++++++----
 drivers/usb/gadget/udc/mv_udc_core.c     | 10 ++++++----
 drivers/usb/gadget/udc/net2272.c         | 11 ++++++-----
 drivers/usb/gadget/udc/net2280.c         | 11 +++++++----
 drivers/usb/gadget/udc/omap_udc.c        | 10 ++++++----
 drivers/usb/gadget/udc/pxa25x_udc.c      | 11 +++++++----
 drivers/usb/gadget/udc/pxa27x_udc.c      |  9 +++++----
 drivers/usb/gadget/udc/s3c-hsudc.c       | 10 ++++++----
 drivers/usb/gadget/udc/s3c2410_udc.c     | 11 ++++++-----
 drivers/usb/gadget/udc/tegra-xudc.c      | 10 ++++++----
 drivers/usb/gadget/udc/udc-xilinx.c      | 11 +++++++----
 26 files changed, 184 insertions(+), 123 deletions(-)


base-commit: 719fce7539cd3e186598e2aed36325fe892150cf
--
2.25.1


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

* [PATCH 01/26] usb: gadget: fsl: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 18:39   ` Linus Torvalds
  2022-03-06 17:50 ` [PATCH 02/26] usb: gadget: bdc: " Jakob Koschel
                   ` (24 subsequent siblings)
  25 siblings, 1 reply; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/fsl_qe_udc.c   | 11 +++++++----
 drivers/usb/gadget/udc/fsl_udc_core.c | 11 +++++++----
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c
index 15db7a3868fe..3979a2825e3c 100644
--- a/drivers/usb/gadget/udc/fsl_qe_udc.c
+++ b/drivers/usb/gadget/udc/fsl_qe_udc.c
@@ -1776,7 +1776,8 @@ static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
 static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct qe_ep *ep = container_of(_ep, struct qe_ep, ep);
-	struct qe_req *req;
+	struct qe_req *req = NULL;
+	struct qe_req *tmp;
 	unsigned long flags;
 
 	if (!_ep || !_req)
@@ -1785,12 +1786,14 @@ static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	spin_lock_irqsave(&ep->udc->lock, flags);
 
 	/* make sure it's actually queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
 
-	if (&req->req != _req) {
+	if (!req) {
 		spin_unlock_irqrestore(&ep->udc->lock, flags);
 		return -EINVAL;
 	}
diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c
index 29fcb9b461d7..23d670fae12c 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -918,7 +918,8 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
 static int fsl_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct fsl_ep *ep = container_of(_ep, struct fsl_ep, ep);
-	struct fsl_req *req;
+	struct fsl_req *req = NULL;
+	struct fsl_req *tmp;
 	unsigned long flags;
 	int ep_num, stopped, ret = 0;
 	u32 epctrl;
@@ -940,11 +941,13 @@ static int fsl_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	fsl_writel(epctrl, &dr_regs->endptctrl[ep_num]);
 
 	/* make sure it's actually queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		ret = -EINVAL;
 		goto out;
 	}
-- 
2.25.1


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

* [PATCH 02/26] usb: gadget: bdc: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
  2022-03-06 17:50 ` [PATCH 01/26] usb: gadget: fsl: remove usage of list iterator past the loop body Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 03/26] usb: gadget: udc: atmel: " Jakob Koschel
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/bdc/bdc_ep.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index 8e2f20b12519..829e96791d0a 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -1757,6 +1757,7 @@ static int bdc_gadget_ep_dequeue(struct usb_ep *_ep,
 				  struct usb_request *_req)
 {
 	struct bdc_req *req;
+	struct bdc_req *tmp;
 	unsigned long flags;
 	struct bdc_ep *ep;
 	struct bdc *bdc;
@@ -1771,12 +1772,16 @@ static int bdc_gadget_ep_dequeue(struct usb_ep *_ep,
 	dev_dbg(bdc->dev, "%s ep:%s req:%p\n", __func__, ep->name, req);
 	bdc_dbg_bd_list(bdc, ep);
 	spin_lock_irqsave(&bdc->lock, flags);
+
+	req = NULL;
 	/* make sure it's still queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->usb_req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->usb_req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->usb_req != _req) {
+	if (!req) {
 		spin_unlock_irqrestore(&bdc->lock, flags);
 		dev_err(bdc->dev, "usb_req !=req n");
 		return -EINVAL;
-- 
2.25.1


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

* [PATCH 03/26] usb: gadget: udc: atmel: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
  2022-03-06 17:50 ` [PATCH 01/26] usb: gadget: fsl: remove usage of list iterator past the loop body Jakob Koschel
  2022-03-06 17:50 ` [PATCH 02/26] usb: gadget: bdc: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 04/26] usb: gadget: udc: pxa25x: " Jakob Koschel
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 2b893bceea45..8e393e14f137 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -860,7 +860,8 @@ static int usba_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct usba_ep *ep = to_usba_ep(_ep);
 	struct usba_udc *udc = ep->udc;
-	struct usba_request *req;
+	struct usba_request *req = NULL;
+	struct usba_request *tmp;
 	unsigned long flags;
 	u32 status;
 
@@ -869,12 +870,14 @@ static int usba_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 
 	spin_lock_irqsave(&udc->lock, flags);
 
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
 
-	if (&req->req != _req) {
+	if (!req) {
 		spin_unlock_irqrestore(&udc->lock, flags);
 		return -EINVAL;
 	}
-- 
2.25.1


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

* [PATCH 04/26] usb: gadget: udc: pxa25x: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (2 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 03/26] usb: gadget: udc: atmel: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 05/26] usb: gadget: udc: at91: " Jakob Koschel
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/pxa25x_udc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c
index b38747fd3bb0..889ea52bbe0a 100644
--- a/drivers/usb/gadget/udc/pxa25x_udc.c
+++ b/drivers/usb/gadget/udc/pxa25x_udc.c
@@ -966,7 +966,8 @@ static void nuke(struct pxa25x_ep *ep, int status)
 static int pxa25x_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct pxa25x_ep	*ep;
-	struct pxa25x_request	*req;
+	struct pxa25x_request	*req = NULL;
+	struct pxa25x_request	*tmp;
 	unsigned long		flags;
 
 	ep = container_of(_ep, struct pxa25x_ep, ep);
@@ -976,11 +977,13 @@ static int pxa25x_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	local_irq_save(flags);
 
 	/* make sure it's actually queued on this endpoint */
-	list_for_each_entry (req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		local_irq_restore(flags);
 		return -EINVAL;
 	}
-- 
2.25.1


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

* [PATCH 05/26] usb: gadget: udc: at91: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (3 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 04/26] usb: gadget: udc: pxa25x: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 06/26] usb: gadget: goku_udc: " Jakob Koschel
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/at91_udc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
index 9040a0561466..3578b061a3ee 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -704,7 +704,7 @@ static int at91_ep_queue(struct usb_ep *_ep,
 static int at91_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct at91_ep		*ep;
-	struct at91_request	*req;
+	struct at91_request	*req = NULL, *tmp;
 	unsigned long		flags;
 	struct at91_udc		*udc;
 
@@ -717,11 +717,13 @@ static int at91_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	spin_lock_irqsave(&udc->lock, flags);
 
 	/* make sure it's actually queued on this endpoint */
-	list_for_each_entry (req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		spin_unlock_irqrestore(&udc->lock, flags);
 		return -EINVAL;
 	}
-- 
2.25.1


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

* [PATCH 06/26] usb: gadget: goku_udc: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (4 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 05/26] usb: gadget: udc: at91: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 07/26] usb: gadget: udc: gr_udc: " Jakob Koschel
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/goku_udc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c
index 3757a772a55e..62153e964655 100644
--- a/drivers/usb/gadget/udc/goku_udc.c
+++ b/drivers/usb/gadget/udc/goku_udc.c
@@ -809,7 +809,7 @@ static void nuke(struct goku_ep *ep, int status)
 /* dequeue JUST ONE request */
 static int goku_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
-	struct goku_request	*req;
+	struct goku_request	*req = NULL, *tmp;
 	struct goku_ep		*ep;
 	struct goku_udc		*dev;
 	unsigned long		flags;
@@ -833,11 +833,13 @@ static int goku_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	spin_lock_irqsave(&dev->lock, flags);
 
 	/* make sure it's actually queued on this endpoint */
-	list_for_each_entry (req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		spin_unlock_irqrestore (&dev->lock, flags);
 		return -EINVAL;
 	}
-- 
2.25.1


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

* [PATCH 07/26] usb: gadget: udc: gr_udc: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (5 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 06/26] usb: gadget: goku_udc: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 08/26] usb: gadget: lpc32xx_udc: " Jakob Koschel
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/gr_udc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c
index 4b35739d3695..9a940c8f1664 100644
--- a/drivers/usb/gadget/udc/gr_udc.c
+++ b/drivers/usb/gadget/udc/gr_udc.c
@@ -1690,7 +1690,7 @@ static int gr_queue_ext(struct usb_ep *_ep, struct usb_request *_req,
 /* Dequeue JUST ONE request */
 static int gr_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
-	struct gr_request *req;
+	struct gr_request *req = NULL, *tmp;
 	struct gr_ep *ep;
 	struct gr_udc *dev;
 	int ret = 0;
@@ -1710,11 +1710,13 @@ static int gr_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	spin_lock_irqsave(&dev->lock, flags);
 
 	/* Make sure it's actually queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		ret = -EINVAL;
 		goto out;
 	}
-- 
2.25.1


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

* [PATCH 08/26] usb: gadget: lpc32xx_udc: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (6 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 07/26] usb: gadget: udc: gr_udc: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 09/26] usb: gadget: mv_u3d: " Jakob Koschel
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/lpc32xx_udc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c
index a25d01c89564..fbb235b1f23f 100644
--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
+++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
@@ -1830,7 +1830,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
 static int lpc32xx_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct lpc32xx_ep *ep;
-	struct lpc32xx_request *req;
+	struct lpc32xx_request *req = NULL, *tmp;
 	unsigned long flags;
 
 	ep = container_of(_ep, struct lpc32xx_ep, ep);
@@ -1840,11 +1840,13 @@ static int lpc32xx_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	spin_lock_irqsave(&ep->udc->lock, flags);
 
 	/* make sure it's actually queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		spin_unlock_irqrestore(&ep->udc->lock, flags);
 		return -EINVAL;
 	}
-- 
2.25.1


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

* [PATCH 09/26] usb: gadget: mv_u3d: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (7 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 08/26] usb: gadget: lpc32xx_udc: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 10/26] usb: gadget: udc: mv_udc_core: " Jakob Koschel
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/mv_u3d_core.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c
index a1057ddfbda3..fd4e9fb661fc 100644
--- a/drivers/usb/gadget/udc/mv_u3d_core.c
+++ b/drivers/usb/gadget/udc/mv_u3d_core.c
@@ -844,7 +844,7 @@ mv_u3d_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
 static int mv_u3d_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct mv_u3d_ep *ep;
-	struct mv_u3d_req *req;
+	struct mv_u3d_req *req = NULL, *tmp;
 	struct mv_u3d *u3d;
 	struct mv_u3d_ep_context *ep_context;
 	struct mv_u3d_req *next_req;
@@ -861,11 +861,13 @@ static int mv_u3d_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	spin_lock_irqsave(&ep->u3d->lock, flags);
 
 	/* make sure it's actually queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		ret = -EINVAL;
 		goto out;
 	}
-- 
2.25.1


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

* [PATCH 10/26] usb: gadget: udc: mv_udc_core: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (8 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 09/26] usb: gadget: mv_u3d: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 11/26] usb: gadget: net2272: " Jakob Koschel
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/mv_udc_core.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
index b6d34dda028b..67d935d29cb6 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -771,7 +771,7 @@ static void mv_prime_ep(struct mv_ep *ep, struct mv_req *req)
 static int mv_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct mv_ep *ep = container_of(_ep, struct mv_ep, ep);
-	struct mv_req *req;
+	struct mv_req *req = NULL, *tmp;
 	struct mv_udc *udc = ep->udc;
 	unsigned long flags;
 	int stopped, ret = 0;
@@ -793,11 +793,13 @@ static int mv_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	writel(epctrlx, &udc->op_regs->epctrlx[ep->ep_num]);
 
 	/* make sure it's actually queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		ret = -EINVAL;
 		goto out;
 	}
-- 
2.25.1


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

* [PATCH 11/26] usb: gadget: net2272: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (9 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 10/26] usb: gadget: udc: mv_udc_core: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 12/26] usb: gadget: udc: net2280: " Jakob Koschel
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/net2272.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c
index 7c38057dcb4a..08ce0831c5e0 100644
--- a/drivers/usb/gadget/udc/net2272.c
+++ b/drivers/usb/gadget/udc/net2272.c
@@ -926,7 +926,7 @@ static int
 net2272_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct net2272_ep *ep;
-	struct net2272_request *req;
+	struct net2272_request *req = NULL, *tmp;
 	unsigned long flags;
 	int stopped;
 
@@ -939,11 +939,13 @@ net2272_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	ep->stopped = 1;
 
 	/* make sure it's still queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		ep->stopped = stopped;
 		spin_unlock_irqrestore(&ep->dev->lock, flags);
 		return -EINVAL;
@@ -954,7 +956,6 @@ net2272_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 		dev_dbg(ep->dev->dev, "unlink (%s) pio\n", _ep->name);
 		net2272_done(ep, req, -ECONNRESET);
 	}
-	req = NULL;
 	ep->stopped = stopped;
 
 	spin_unlock_irqrestore(&ep->dev->lock, flags);
-- 
2.25.1


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

* [PATCH 12/26] usb: gadget: udc: net2280: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (10 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 11/26] usb: gadget: net2272: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 13/26] usb: gadget: omap_udc: " Jakob Koschel
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 16e7d2db6411..dbf5592dbcf0 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1240,7 +1240,8 @@ static void nuke(struct net2280_ep *ep)
 static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct net2280_ep	*ep;
-	struct net2280_request	*req;
+	struct net2280_request	*req = NULL;
+	struct net2280_request	*tmp;
 	unsigned long		flags;
 	u32			dmactl;
 	int			stopped;
@@ -1266,11 +1267,13 @@ static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	}
 
 	/* make sure it's still queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		ep->stopped = stopped;
 		spin_unlock_irqrestore(&ep->dev->lock, flags);
 		ep_dbg(ep->dev, "%s: Request mismatch\n", __func__);
-- 
2.25.1


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

* [PATCH 13/26] usb: gadget: omap_udc: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (11 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 12/26] usb: gadget: udc: net2280: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 14/26] usb: gadget: s3c-hsudc: " Jakob Koschel
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/omap_udc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/omap_udc.c b/drivers/usb/gadget/udc/omap_udc.c
index 494da00398d7..e48a89baf44e 100644
--- a/drivers/usb/gadget/udc/omap_udc.c
+++ b/drivers/usb/gadget/udc/omap_udc.c
@@ -1003,7 +1003,7 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
 static int omap_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct omap_ep	*ep = container_of(_ep, struct omap_ep, ep);
-	struct omap_req	*req;
+	struct omap_req	*req = NULL, *tmp;
 	unsigned long	flags;
 
 	if (!_ep || !_req)
@@ -1012,11 +1012,13 @@ static int omap_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	spin_lock_irqsave(&ep->udc->lock, flags);
 
 	/* make sure it's actually queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->req != _req) {
+	if (!req) {
 		spin_unlock_irqrestore(&ep->udc->lock, flags);
 		return -EINVAL;
 	}
-- 
2.25.1


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

* [PATCH 14/26] usb: gadget: s3c-hsudc: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (12 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 13/26] usb: gadget: omap_udc: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 15/26] usb: gadget: udc-xilinx: " Jakob Koschel
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/s3c-hsudc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c
index 89f1f8c9f02e..ddfc30b1d248 100644
--- a/drivers/usb/gadget/udc/s3c-hsudc.c
+++ b/drivers/usb/gadget/udc/s3c-hsudc.c
@@ -877,7 +877,7 @@ static int s3c_hsudc_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct s3c_hsudc_ep *hsep = our_ep(_ep);
 	struct s3c_hsudc *hsudc = hsep->dev;
-	struct s3c_hsudc_req *hsreq;
+	struct s3c_hsudc_req *hsreq = NULL, *tmp;
 	unsigned long flags;
 
 	hsep = our_ep(_ep);
@@ -886,11 +886,13 @@ static int s3c_hsudc_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 
 	spin_lock_irqsave(&hsudc->lock, flags);
 
-	list_for_each_entry(hsreq, &hsep->queue, queue) {
-		if (&hsreq->req == _req)
+	list_for_each_entry(tmp, &hsep->queue, queue) {
+		if (&tmp->req == _req) {
+			hsreq = tmp;
 			break;
+		}
 	}
-	if (&hsreq->req != _req) {
+	if (!hsreq) {
 		spin_unlock_irqrestore(&hsudc->lock, flags);
 		return -EINVAL;
 	}
-- 
2.25.1


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

* [PATCH 15/26] usb: gadget: udc-xilinx: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (13 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 14/26] usb: gadget: s3c-hsudc: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 16/26] usb: gadget: aspeed: " Jakob Koschel
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/udc-xilinx.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
index 2907fad04e2c..34b7000f0602 100644
--- a/drivers/usb/gadget/udc/udc-xilinx.c
+++ b/drivers/usb/gadget/udc/udc-xilinx.c
@@ -1136,17 +1136,20 @@ static int xudc_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
 static int xudc_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct xusb_ep *ep	= to_xusb_ep(_ep);
-	struct xusb_req *req	= to_xusb_req(_req);
+	struct xusb_req *req	= NULL;
+	struct xusb_req *tmp;
 	struct xusb_udc *udc	= ep->udc;
 	unsigned long flags;
 
 	spin_lock_irqsave(&udc->lock, flags);
 	/* Make sure it's actually queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->usb_req == _req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->usb_req == _req) {
+			req = tmp;
 			break;
+		}
 	}
-	if (&req->usb_req != _req) {
+	if (!req) {
 		spin_unlock_irqrestore(&udc->lock, flags);
 		return -EINVAL;
 	}
-- 
2.25.1


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

* [PATCH 16/26] usb: gadget: aspeed: remove usage of list iterator past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (14 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 15/26] usb: gadget: udc-xilinx: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 17/26] usb: gadget: configfs: remove using list iterator after loop body as a ptr Jakob Koschel
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list representing the request queue does not contain the expected
request, the value of the list_for_each_entry() iterator will not point
to a valid structure. To avoid type confusion in such case, the list
iterator scope will be limited to the list_for_each_entry() loop.

In preparation to limiting scope of the list iterator to the list traversal
loop, use a dedicated pointer to point to the found request object [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/aspeed-vhub/epn.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/aspeed-vhub/epn.c b/drivers/usb/gadget/udc/aspeed-vhub/epn.c
index 917892ca8753..82b54b6a052b 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/epn.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/epn.c
@@ -466,19 +466,21 @@ static int ast_vhub_epn_dequeue(struct usb_ep* u_ep, struct usb_request *u_req)
 {
 	struct ast_vhub_ep *ep = to_ast_ep(u_ep);
 	struct ast_vhub *vhub = ep->vhub;
-	struct ast_vhub_req *req;
+	struct ast_vhub_req *req = NULL, *tmp;
 	unsigned long flags;
 	int rc = -EINVAL;
 
 	spin_lock_irqsave(&vhub->lock, flags);
 
 	/* Make sure it's actually queued on this endpoint */
-	list_for_each_entry (req, &ep->queue, queue) {
-		if (&req->req == u_req)
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == u_req) {
+			req = tmp;
 			break;
+		}
 	}
 
-	if (&req->req == u_req) {
+	if (req) {
 		EPVDBG(ep, "dequeue req @%p active=%d\n",
 		       req, req->active);
 		if (req->active)
-- 
2.25.1


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

* [PATCH 17/26] usb: gadget: configfs: remove using list iterator after loop body as a ptr
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (15 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 16/26] usb: gadget: aspeed: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 18/26] usb: gadget: legacy: " Jakob Koschel
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list does not contain the expected element, the value of
list_for_each_entry() iterator will not point to a valid structure.
To avoid type confusion in such case, the list iterator
scope will be limited to list_for_each_entry() loop.

In preparation to limiting scope of a list iterator to the list traversal
loop, use a dedicated pointer to point to the found element [1].
Determining if an element was found is then simply checking if
the pointer is != NULL instead of using the potentially bogus pointer.

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/configfs.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index d4a678c0806e..938cd43e74c6 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -418,7 +418,7 @@ static int config_usb_cfg_link(
 
 	struct usb_function_instance *fi =
 			to_usb_function_instance(usb_func_ci);
-	struct usb_function_instance *a_fi;
+	struct usb_function_instance *a_fi = NULL, *tmp;
 	struct usb_function *f;
 	int ret;
 
@@ -428,11 +428,13 @@ static int config_usb_cfg_link(
 	 * from another gadget or a random directory.
 	 * Also a function instance can only be linked once.
 	 */
-	list_for_each_entry(a_fi, &gi->available_func, cfs_list) {
-		if (a_fi == fi)
+	list_for_each_entry(tmp, &gi->available_func, cfs_list) {
+		if (tmp == fi) {
+			a_fi = tmp;
 			break;
+		}
 	}
-	if (a_fi != fi) {
+	if (!a_fi) {
 		ret = -EINVAL;
 		goto out;
 	}
@@ -882,15 +884,17 @@ static int os_desc_link(struct config_item *os_desc_ci,
 	struct gadget_info *gi = os_desc_item_to_gadget_info(os_desc_ci);
 	struct usb_composite_dev *cdev = &gi->cdev;
 	struct config_usb_cfg *c_target = to_config_usb_cfg(usb_cfg_ci);
-	struct usb_configuration *c;
+	struct usb_configuration *c = NULL, *tmp;
 	int ret;
 
 	mutex_lock(&gi->lock);
-	list_for_each_entry(c, &cdev->configs, list) {
-		if (c == &c_target->c)
+	list_for_each_entry(tmp, &cdev->configs, list) {
+		if (tmp == &c_target->c) {
+			c = tmp;
 			break;
+		}
 	}
-	if (c != &c_target->c) {
+	if (!c) {
 		ret = -EINVAL;
 		goto out;
 	}
-- 
2.25.1


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

* [PATCH 18/26] usb: gadget: legacy: remove using list iterator after loop body as a ptr
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (16 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 17/26] usb: gadget: configfs: remove using list iterator after loop body as a ptr Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 19/26] usb: gadget: udc: max3420_udc: " Jakob Koschel
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list does not contain the expected element, the value of
list_for_each_entry() iterator will not point to a valid structure.
To avoid type confusion in such case, the list iterator
scope will be limited to list_for_each_entry() loop.

In preparation to limiting scope of a list iterator to the list traversal
loop, use a dedicated pointer to point to the found element [1].
Determining if an element was found is then simply checking if
the pointer is != NULL instead of using the potentially bogus pointer.

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/legacy/hid.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
index 3912cc805f3a..b7f1ff2ce951 100644
--- a/drivers/usb/gadget/legacy/hid.c
+++ b/drivers/usb/gadget/legacy/hid.c
@@ -134,7 +134,7 @@ static int hid_bind(struct usb_composite_dev *cdev)
 {
 	struct usb_gadget *gadget = cdev->gadget;
 	struct list_head *tmp;
-	struct hidg_func_node *n, *m;
+	struct hidg_func_node *n = NULL, *m, *tmp_n;
 	struct f_hid_opts *hid_opts;
 	int status, funcs = 0;
 
@@ -144,18 +144,19 @@ static int hid_bind(struct usb_composite_dev *cdev)
 	if (!funcs)
 		return -ENODEV;
 
-	list_for_each_entry(n, &hidg_func_list, node) {
-		n->fi = usb_get_function_instance("hid");
-		if (IS_ERR(n->fi)) {
-			status = PTR_ERR(n->fi);
+	list_for_each_entry(tmp_n, &hidg_func_list, node) {
+		tmp_n->fi = usb_get_function_instance("hid");
+		if (IS_ERR(tmp_n->fi)) {
+			status = PTR_ERR(tmp_n->fi);
+			n = tmp_n;
 			goto put;
 		}
-		hid_opts = container_of(n->fi, struct f_hid_opts, func_inst);
-		hid_opts->subclass = n->func->subclass;
-		hid_opts->protocol = n->func->protocol;
-		hid_opts->report_length = n->func->report_length;
-		hid_opts->report_desc_length = n->func->report_desc_length;
-		hid_opts->report_desc = n->func->report_desc;
+		hid_opts = container_of(tmp_n->fi, struct f_hid_opts, func_inst);
+		hid_opts->subclass = tmp_n->func->subclass;
+		hid_opts->protocol = tmp_n->func->protocol;
+		hid_opts->report_length = tmp_n->func->report_length;
+		hid_opts->report_desc_length = tmp_n->func->report_desc_length;
+		hid_opts->report_desc = tmp_n->func->report_desc;
 	}
 
 
-- 
2.25.1


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

* [PATCH 19/26] usb: gadget: udc: max3420_udc: remove using list iterator after loop body as a ptr
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (17 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 18/26] usb: gadget: legacy: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 20/26] usb: gadget: tegra-xudc: " Jakob Koschel
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list does not contain the expected element, the value of
list_for_each_entry() iterator will not point to a valid structure.
To avoid type confusion in such case, the list iterator
scope will be limited to list_for_each_entry() loop.

In preparation to limiting scope of a list iterator to the list traversal
loop, use a dedicated pointer to point to the found element [1].
Determining if an element was found is then simply checking if
the pointer is != NULL instead of using the potentially bogus pointer.

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/max3420_udc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/max3420_udc.c b/drivers/usb/gadget/udc/max3420_udc.c
index d2a2b20cc1ad..d1b010b5f4a0 100644
--- a/drivers/usb/gadget/udc/max3420_udc.c
+++ b/drivers/usb/gadget/udc/max3420_udc.c
@@ -1044,22 +1044,25 @@ static int max3420_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
 
 static int max3420_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
-	struct max3420_req *t, *req = to_max3420_req(_req);
+	struct max3420_req *t = NULL;
+	struct max3420_req *req = to_max3420_req(_req);
+	struct max3420_req *tmp;
 	struct max3420_ep *ep = to_max3420_ep(_ep);
 	unsigned long flags;
 
 	spin_lock_irqsave(&ep->lock, flags);
 
 	/* Pluck the descriptor from queue */
-	list_for_each_entry(t, &ep->queue, queue)
-		if (t == req) {
+	list_for_each_entry(tmp, &ep->queue, queue)
+		if (tmp == req) {
 			list_del_init(&req->queue);
+			t = tmp;
 			break;
 		}
 
 	spin_unlock_irqrestore(&ep->lock, flags);
 
-	if (t == req)
+	if (t)
 		max3420_req_done(req, -ECONNRESET);
 
 	return 0;
-- 
2.25.1


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

* [PATCH 20/26] usb: gadget: tegra-xudc: remove using list iterator after loop body as a ptr
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (18 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 19/26] usb: gadget: udc: max3420_udc: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 21/26] usb: gadget: composite: remove check of list iterator against head past the loop body Jakob Koschel
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

If the list does not contain the expected element, the value of
list_for_each_entry() iterator will not point to a valid structure.
To avoid type confusion in such case, the list iterator
scope will be limited to list_for_each_entry() loop.

In preparation to limiting scope of a list iterator to the list traversal
loop, use a dedicated pointer to point to the found element [1].
Determining if an element was found is then simply checking if
the pointer is != NULL instead of using the potentially bogus pointer.

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/tegra-xudc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
index 43f1b0d461c1..7c39d8a9e49d 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -1413,18 +1413,20 @@ __tegra_xudc_ep_dequeue(struct tegra_xudc_ep *ep,
 			struct tegra_xudc_request *req)
 {
 	struct tegra_xudc *xudc = ep->xudc;
-	struct tegra_xudc_request *r;
+	struct tegra_xudc_request *r = NULL, *tmp;
 	struct tegra_xudc_trb *deq_trb;
 	bool busy, kick_queue = false;
 	int ret = 0;
 
 	/* Make sure the request is actually queued to this endpoint. */
-	list_for_each_entry(r, &ep->queue, list) {
-		if (r == req)
+	list_for_each_entry(tmp, &ep->queue, list) {
+		if (tmp == req) {
+			r = tmp;
 			break;
+		}
 	}
 
-	if (r != req)
+	if (!r)
 		return -EINVAL;
 
 	/* Request hasn't been queued in the transfer ring yet. */
-- 
2.25.1


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

* [PATCH 21/26] usb: gadget: composite: remove check of list iterator against head past the loop body
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (19 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 20/26] usb: gadget: tegra-xudc: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 22/26] usb: gadget: pxa27x_udc: replace usage of rc to check if a list element was found Jakob Koschel
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

When list_for_each_entry() completes the iteration over the whole list
without breaking the loop, the iterator value will be a bogus pointer
computed based on the head element.

While it is safe to use the pointer to determine if it was computed
based on the head element, either with list_entry_is_head() or
&pos->member == head, using the iterator variable after the loop should
be avoided.

In preparation to limiting the scope of a list iterator to the list
traversal loop, use a dedicated pointer to point to the found element [1].

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/composite.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 9315313108c9..26908d012ac8 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1690,6 +1690,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
 	u16				w_value = le16_to_cpu(ctrl->wValue);
 	u16				w_length = le16_to_cpu(ctrl->wLength);
 	struct usb_function		*f = NULL;
+	struct usb_function		*tmp;
 	u8				endp;
 
 	if (w_length > USB_COMP_EP0_BUFSIZ) {
@@ -2046,12 +2047,12 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
 			if (!cdev->config)
 				break;
 			endp = ((w_index & 0x80) >> 3) | (w_index & 0x0f);
-			list_for_each_entry(f, &cdev->config->functions, list) {
-				if (test_bit(endp, f->endpoints))
+			list_for_each_entry(tmp, &cdev->config->functions, list) {
+				if (test_bit(endp, tmp->endpoints)) {
+					f = tmp;
 					break;
+				}
 			}
-			if (&f->list == &cdev->config->functions)
-				f = NULL;
 			break;
 		}
 try_fun_setup:
-- 
2.25.1


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

* [PATCH 22/26] usb: gadget: pxa27x_udc: replace usage of rc to check if a list element was found
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (20 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 21/26] usb: gadget: composite: remove check of list iterator against head past the loop body Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 23/26] usb: gadget: udc: s3c2410: " Jakob Koschel
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable [1].

This removes the need to check the rc value to determine if the
break/goto was hit and can be made more obvious
by checking if the variable was set within the list traversal loop.

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/pxa27x_udc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
index f4b7a2a3e711..eed793deeda0 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -1159,7 +1159,7 @@ static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct pxa_ep		*ep;
 	struct udc_usb_ep	*udc_usb_ep;
-	struct pxa27x_request	*req;
+	struct pxa27x_request	*req = NULL, *tmp;
 	unsigned long		flags;
 	int			rc = -EINVAL;
 
@@ -1173,15 +1173,16 @@ static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	spin_lock_irqsave(&ep->lock, flags);
 
 	/* make sure it's actually queued on this endpoint */
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req) {
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			req = tmp;
 			rc = 0;
 			break;
 		}
 	}
 
 	spin_unlock_irqrestore(&ep->lock, flags);
-	if (!rc)
+	if (req)
 		req_done(ep, req, -ECONNRESET, NULL);
 	return rc;
 }
-- 
2.25.1


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

* [PATCH 23/26] usb: gadget: udc: s3c2410: replace usage of rc to check if a list element was found
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (21 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 22/26] usb: gadget: pxa27x_udc: replace usage of rc to check if a list element was found Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 24/26] usb: gadget: udc: core: " Jakob Koschel
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable [1].

This removes the need to check the rc value to determine if the
break/goto was hit and can be made more obvious
by checking if the variable was set within the list traversal loop.

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/composite.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 26908d012ac8..fa9f4aedf52d 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -863,14 +863,14 @@ static int set_config(struct usb_composite_dev *cdev,
 		const struct usb_ctrlrequest *ctrl, unsigned number)
 {
 	struct usb_gadget	*gadget = cdev->gadget;
-	struct usb_configuration *c = NULL;
+	struct usb_configuration *c = NULL, *iter;
 	int			result = -EINVAL;
 	unsigned		power = gadget_is_otg(gadget) ? 8 : 100;
 	int			tmp;
 
 	if (number) {
-		list_for_each_entry(c, &cdev->configs, list) {
-			if (c->bConfigurationValue == number) {
+		list_for_each_entry(iter, &cdev->configs, list) {
+			if (iter->bConfigurationValue == number) {
 				/*
 				 * We disable the FDs of the previous
 				 * configuration only if the new configuration
@@ -878,11 +878,12 @@ static int set_config(struct usb_composite_dev *cdev,
 				 */
 				if (cdev->config)
 					reset_config(cdev);
+				c = iter;
 				result = 0;
 				break;
 			}
 		}
-		if (result < 0)
+		if (!c)
 			goto done;
 	} else { /* Zero configuration value - need to reset the config */
 		if (cdev->config)
-- 
2.25.1


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

* [PATCH 24/26] usb: gadget: udc: core: replace usage of rc to check if a list element was found
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (22 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 23/26] usb: gadget: udc: s3c2410: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 17:50 ` [PATCH 25/26] usb: gadget: dummy_hcd: " Jakob Koschel
  2022-03-06 17:50 ` [PATCH 26/26] usb: gadget: udc: s3c2410: " Jakob Koschel
  25 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable [1].

This removes the need to check the rc value to determine if the
break/goto was hit and can be made more obvious
by checking if the variable was set within the list traversal loop.

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/core.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 568534a0d17c..d3c269ce3851 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1528,7 +1528,7 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
 
 int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
 {
-	struct usb_udc		*udc = NULL;
+	struct usb_udc		*udc = NULL, *tmp;
 	int			ret = -ENODEV;
 
 	if (!driver || !driver->bind || !driver->setup)
@@ -1536,10 +1536,12 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
 
 	mutex_lock(&udc_lock);
 	if (driver->udc_name) {
-		list_for_each_entry(udc, &udc_list, list) {
-			ret = strcmp(driver->udc_name, dev_name(&udc->dev));
-			if (!ret)
+		list_for_each_entry(tmp, &udc_list, list) {
+			ret = strcmp(driver->udc_name, dev_name(&tmp->dev));
+			if (!ret) {
+				udc = tmp;
 				break;
+			}
 		}
 		if (ret)
 			ret = -ENODEV;
@@ -1548,10 +1550,12 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
 		else
 			goto found;
 	} else {
-		list_for_each_entry(udc, &udc_list, list) {
+		list_for_each_entry(tmp, &udc_list, list) {
 			/* For now we take the first one */
-			if (!udc->driver)
+			if (!tmp->driver) {
+				udc = tmp;
 				goto found;
+			}
 		}
 	}
 
-- 
2.25.1


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

* [PATCH 25/26] usb: gadget: dummy_hcd: replace usage of rc to check if a list element was found
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (23 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 24/26] usb: gadget: udc: core: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-06 18:00   ` Greg KH
  2022-03-06 17:50 ` [PATCH 26/26] usb: gadget: udc: s3c2410: " Jakob Koschel
  25 siblings, 1 reply; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable [1].

This removes the need to check the rc value to determine if the
break/goto was hit and can be made more obvious
by checking if the variable was set within the list traversal loop.

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/dummy_hcd.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index a2d956af42a2..f21944707707 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -751,7 +751,7 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	struct dummy		*dum;
 	int			retval = -EINVAL;
 	unsigned long		flags;
-	struct dummy_request	*req = NULL;
+	struct dummy_request	*req = NULL, *tmp;
 
 	if (!_ep || !_req)
 		return retval;
@@ -763,17 +763,18 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 
 	local_irq_save(flags);
 	spin_lock(&dum->lock);
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req) {
-			list_del_init(&req->queue);
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			list_del_init(&tmp->queue);
 			_req->status = -ECONNRESET;
+			req = tmp;
 			retval = 0;
 			break;
 		}
 	}
 	spin_unlock(&dum->lock);
 
-	if (retval == 0) {
+	if (req) {
 		dev_dbg(udc_dev(dum),
 				"dequeued req %p from %s, len %d buf %p\n",
 				req, _ep->name, _req->length, _req->buf);
-- 
2.25.1


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

* [PATCH 26/26] usb: gadget: udc: s3c2410: replace usage of rc to check if a list element was found
  2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
                   ` (24 preceding siblings ...)
  2022-03-06 17:50 ` [PATCH 25/26] usb: gadget: dummy_hcd: " Jakob Koschel
@ 2022-03-06 17:50 ` Jakob Koschel
  2022-03-07 12:13   ` Krzysztof Kozlowski
  25 siblings, 1 reply; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 17:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jakob Koschel, linux-kernel, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable [1].

This removes the need to check the rc value to determine if the
break/goto was hit and can be made more obvious
by checking if the variable was set within the list traversal loop.

Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 drivers/usb/gadget/udc/s3c2410_udc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c
index e3931da24277..fe6ecb0d16d1 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -1265,7 +1265,7 @@ static int s3c2410_udc_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 	struct s3c2410_ep	*ep = to_s3c2410_ep(_ep);
 	int			retval = -EINVAL;
 	unsigned long		flags;
-	struct s3c2410_request	*req = NULL;
+	struct s3c2410_request	*req = NULL, *tmp;
 
 	dprintk(DEBUG_VERBOSE, "%s(%p,%p)\n", __func__, _ep, _req);
 
@@ -1277,16 +1277,17 @@ static int s3c2410_udc_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 
 	local_irq_save(flags);
 
-	list_for_each_entry(req, &ep->queue, queue) {
-		if (&req->req == _req) {
-			list_del_init(&req->queue);
+	list_for_each_entry(tmp, &ep->queue, queue) {
+		if (&tmp->req == _req) {
+			list_del_init(&tmp->queue);
 			_req->status = -ECONNRESET;
+			req = tmp;
 			retval = 0;
 			break;
 		}
 	}
 
-	if (retval == 0) {
+	if (req) {
 		dprintk(DEBUG_VERBOSE,
 			"dequeued req %p from %s, len %d buf %p\n",
 			req, _ep->name, _req->length, _req->buf);
-- 
2.25.1


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

* Re: [PATCH 25/26] usb: gadget: dummy_hcd: replace usage of rc to check if a list element was found
  2022-03-06 17:50 ` [PATCH 25/26] usb: gadget: dummy_hcd: " Jakob Koschel
@ 2022-03-06 18:00   ` Greg KH
  2022-03-06 19:16     ` Jakob Koschel
  0 siblings, 1 reply; 32+ messages in thread
From: Greg KH @ 2022-03-06 18:00 UTC (permalink / raw)
  To: Jakob Koschel
  Cc: linux-kernel, Linus Torvalds, Felipe Balbi, Joel Stanley,
	Andrew Jeffery, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Cristian Birsan, Al Cooper, Li Yang, Vladimir Zapolskiy,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Krzysztof Kozlowski,
	Alim Akhtar, Thierry Reding, Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

On Sun, Mar 06, 2022 at 06:50:33PM +0100, Jakob Koschel wrote:
> To move the list iterator variable into the list_for_each_entry_*()
> macro in the future it should be avoided to use the list iterator
> variable after the loop body.
> 
> To *never* use the list iterator variable after the loop it was
> concluded to use a separate iterator variable [1].
> 
> This removes the need to check the rc value to determine if the
> break/goto was hit and can be made more obvious
> by checking if the variable was set within the list traversal loop.
> 
> Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
> Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
> ---
>  drivers/usb/gadget/udc/dummy_hcd.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
> index a2d956af42a2..f21944707707 100644
> --- a/drivers/usb/gadget/udc/dummy_hcd.c
> +++ b/drivers/usb/gadget/udc/dummy_hcd.c
> @@ -751,7 +751,7 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req)
>  	struct dummy		*dum;
>  	int			retval = -EINVAL;
>  	unsigned long		flags;
> -	struct dummy_request	*req = NULL;
> +	struct dummy_request	*req = NULL, *tmp;
>  
>  	if (!_ep || !_req)
>  		return retval;
> @@ -763,17 +763,18 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req)
>  
>  	local_irq_save(flags);
>  	spin_lock(&dum->lock);
> -	list_for_each_entry(req, &ep->queue, queue) {
> -		if (&req->req == _req) {
> -			list_del_init(&req->queue);
> +	list_for_each_entry(tmp, &ep->queue, queue) {
> +		if (&tmp->req == _req) {
> +			list_del_init(&tmp->queue);
>  			_req->status = -ECONNRESET;
> +			req = tmp;
>  			retval = 0;
>  			break;
>  		}
>  	}
>  	spin_unlock(&dum->lock);
>  
> -	if (retval == 0) {
> +	if (req) {

There's no need for this change as we are testing retval, not req here,
unlike the other udc drivers.

So this one I think is correct as-is, or am I mistaken somehow?

thanks,

greg k-h

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

* Re: [PATCH 01/26] usb: gadget: fsl: remove usage of list iterator past the loop body
  2022-03-06 17:50 ` [PATCH 01/26] usb: gadget: fsl: remove usage of list iterator past the loop body Jakob Koschel
@ 2022-03-06 18:39   ` Linus Torvalds
  2022-03-06 19:19     ` Jakob Koschel
  0 siblings, 1 reply; 32+ messages in thread
From: Linus Torvalds @ 2022-03-06 18:39 UTC (permalink / raw)
  To: Jakob Koschel
  Cc: Greg Kroah-Hartman, linux-kernel, Felipe Balbi, Joel Stanley,
	Andrew Jeffery, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Cristian Birsan, Al Cooper, Li Yang, Vladimir Zapolskiy,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Krzysztof Kozlowski,
	Alim Akhtar, Thierry Reding, Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

On Sun, Mar 6, 2022 at 9:51 AM Jakob Koschel <jakobkoschel@gmail.com> wrote:
>
>         /* make sure it's actually queued on this endpoint */
> -       list_for_each_entry(req, &ep->queue, queue) {
> -               if (&req->req == _req)
> +       list_for_each_entry(tmp, &ep->queue, queue) {
> +               if (&tmp->req == _req) {
> +                       req = tmp;
>                         break;
> +               }
>         }

Honestly, I think many (most?) of these would be a lot cleaner as

        list_for_each_entry(tmp, &ep->queue, queue) {
                if (&tmp->req != _req)
                        continue;
                req = tmp;
                break;
        }

and in fact maybe that 'tmp' would be better named 'iter' or similar
(maybe 'pos', which is what the list.h macros themselves use for the
iterator naming), just from a naming standpoint.

Because it's not really some temporary variable, it has a real use.

           Linus

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

* Re: [PATCH 25/26] usb: gadget: dummy_hcd: replace usage of rc to check if a list element was found
  2022-03-06 18:00   ` Greg KH
@ 2022-03-06 19:16     ` Jakob Koschel
  0 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 19:16 UTC (permalink / raw)
  To: Greg KH
  Cc: Linux Kernel Mailing List, Linus Torvalds, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.



> On 6. Mar 2022, at 19:00, Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> On Sun, Mar 06, 2022 at 06:50:33PM +0100, Jakob Koschel wrote:
>> To move the list iterator variable into the list_for_each_entry_*()
>> macro in the future it should be avoided to use the list iterator
>> variable after the loop body.
>> 
>> To *never* use the list iterator variable after the loop it was
>> concluded to use a separate iterator variable [1].
>> 
>> This removes the need to check the rc value to determine if the
>> break/goto was hit and can be made more obvious
>> by checking if the variable was set within the list traversal loop.
>> 
>> Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
>> Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
>> ---
>> drivers/usb/gadget/udc/dummy_hcd.c | 11 ++++++-----
>> 1 file changed, 6 insertions(+), 5 deletions(-)
>> 
>> diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
>> index a2d956af42a2..f21944707707 100644
>> --- a/drivers/usb/gadget/udc/dummy_hcd.c
>> +++ b/drivers/usb/gadget/udc/dummy_hcd.c
>> @@ -751,7 +751,7 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req)
>> 	struct dummy		*dum;
>> 	int			retval = -EINVAL;
>> 	unsigned long		flags;
>> -	struct dummy_request	*req = NULL;
>> +	struct dummy_request	*req = NULL, *tmp;
>> 
>> 	if (!_ep || !_req)
>> 		return retval;
>> @@ -763,17 +763,18 @@ static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req)
>> 
>> 	local_irq_save(flags);
>> 	spin_lock(&dum->lock);
>> -	list_for_each_entry(req, &ep->queue, queue) {
>> -		if (&req->req == _req) {
>> -			list_del_init(&req->queue);
>> +	list_for_each_entry(tmp, &ep->queue, queue) {
>> +		if (&tmp->req == _req) {
>> +			list_del_init(&tmp->queue);
>> 			_req->status = -ECONNRESET;
>> +			req = tmp;
>> 			retval = 0;
>> 			break;
>> 		}
>> 	}
>> 	spin_unlock(&dum->lock);
>> 
>> -	if (retval == 0) {
>> +	if (req) {
> 
> There's no need for this change as we are testing retval, not req here,
> unlike the other udc drivers.
> 
> So this one I think is correct as-is, or am I mistaken somehow?

The check is correct as-is. I just felt it would be more explicit to
actually check if the pointer that is used within the block is not
NULL than implicitly checking this through retval. There are other
blocks which do like:

list_for_each_entry(pos, head, list) {
	if (...) {
		rc = -1;
		goto fail;
	}
}

rc = call_unrelated_function(...);
if (rc == -1)
	goto fail;

...

return 0;

fail:
	*pos->member;

While this code is obviously broken and then one in this patch works fine,
I feel like it's easier to follow the rule of always checking of pos != NULL.

It might also make it easier for some static analyzers to find potential
NULL pointer dereferences but it probably doesn't matter.

If you prefer keeping retval I'll just do that instead.

> 
> thanks,
> 
> greg k-h

Jakob


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

* Re: [PATCH 01/26] usb: gadget: fsl: remove usage of list iterator past the loop body
  2022-03-06 18:39   ` Linus Torvalds
@ 2022-03-06 19:19     ` Jakob Koschel
  0 siblings, 0 replies; 32+ messages in thread
From: Jakob Koschel @ 2022-03-06 19:19 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Greg Kroah-Hartman, Linux Kernel Mailing List, Felipe Balbi,
	Joel Stanley, Andrew Jeffery, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Cristian Birsan, Al Cooper, Li Yang,
	Vladimir Zapolskiy, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	Krzysztof Kozlowski, Alim Akhtar, Thierry Reding,
	Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.



> On 6. Mar 2022, at 19:39, Linus Torvalds <torvalds@linux-foundation.org> wrote:
> 
> On Sun, Mar 6, 2022 at 9:51 AM Jakob Koschel <jakobkoschel@gmail.com> wrote:
>> 
>>        /* make sure it's actually queued on this endpoint */
>> -       list_for_each_entry(req, &ep->queue, queue) {
>> -               if (&req->req == _req)
>> +       list_for_each_entry(tmp, &ep->queue, queue) {
>> +               if (&tmp->req == _req) {
>> +                       req = tmp;
>>                        break;
>> +               }
>>        }
> 
> Honestly, I think many (most?) of these would be a lot cleaner as
> 
>        list_for_each_entry(tmp, &ep->queue, queue) {
>                if (&tmp->req != _req)
>                        continue;
>                req = tmp;
>                break;
>        }

Alright, then I'll go ahead and adjust them. I tried keeping the code
as similar as possible because in other cases it might be less cleaner
inverting the condition.

> 
> and in fact maybe that 'tmp' would be better named 'iter' or similar
> (maybe 'pos', which is what the list.h macros themselves use for the
> iterator naming), just from a naming standpoint.

I agree, also here I simply kept it to what we concluded in the other
thread. I also think using 'iter' would make more sense.
> 
> Because it's not really some temporary variable, it has a real use.
> 
>           Linus

Jakob


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

* Re: [PATCH 26/26] usb: gadget: udc: s3c2410: replace usage of rc to check if a list element was found
  2022-03-06 17:50 ` [PATCH 26/26] usb: gadget: udc: s3c2410: " Jakob Koschel
@ 2022-03-07 12:13   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 32+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-07 12:13 UTC (permalink / raw)
  To: Jakob Koschel, Greg Kroah-Hartman
  Cc: linux-kernel, Linus Torvalds, Felipe Balbi, Joel Stanley,
	Andrew Jeffery, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Cristian Birsan, Al Cooper, Li Yang, Vladimir Zapolskiy,
	Daniel Mack, Haojian Zhuang, Robert Jarzmik, Alim Akhtar,
	Thierry Reding, Jonathan Hunter, Michal Simek,
	open list:USB GADGET/PERIPHERAL SUBSYSTEM, Mike Rapoport,
	Brian Johannesmeyer, Cristiano Giuffrida, Bos, H.J.

On 06/03/2022 18:50, Jakob Koschel wrote:
> To move the list iterator variable into the list_for_each_entry_*()
> macro in the future it should be avoided to use the list iterator
> variable after the loop body.
> 
> To *never* use the list iterator variable after the loop it was
> concluded to use a separate iterator variable [1].
> 
> This removes the need to check the rc value to determine if the
> break/goto was hit and can be made more obvious
> by checking if the variable was set within the list traversal loop.
> 
> Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/
> Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
> ---
>  drivers/usb/gadget/udc/s3c2410_udc.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c
> index e3931da24277..fe6ecb0d16d1 100644
> --- a/drivers/usb/gadget/udc/s3c2410_udc.c
> +++ b/drivers/usb/gadget/udc/s3c2410_udc.c
> @@ -1265,7 +1265,7 @@ static int s3c2410_udc_dequeue(struct usb_ep *_ep, struct usb_request *_req)
>  	struct s3c2410_ep	*ep = to_s3c2410_ep(_ep);
>  	int			retval = -EINVAL;
>  	unsigned long		flags;
> -	struct s3c2410_request	*req = NULL;
> +	struct s3c2410_request	*req = NULL, *tmp;
>  
>  	dprintk(DEBUG_VERBOSE, "%s(%p,%p)\n", __func__, _ep, _req);
>  
> @@ -1277,16 +1277,17 @@ static int s3c2410_udc_dequeue(struct usb_ep *_ep, struct usb_request *_req)
>  
>  	local_irq_save(flags);
>  
> -	list_for_each_entry(req, &ep->queue, queue) {
> -		if (&req->req == _req) {
> -			list_del_init(&req->queue);
> +	list_for_each_entry(tmp, &ep->queue, queue) {
> +		if (&tmp->req == _req) {
> +			list_del_init(&tmp->queue);
>  			_req->status = -ECONNRESET;
> +			req = tmp;
>  			retval = 0;
>  			break;
>  		}
>  	}
>  
> -	if (retval == 0) {
> +	if (req) {

I saw comments from Greg about it, so please keep similar approach here
as in patch 25. I propose to keep retval.

With retval restored:
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

Best regards,
Krzysztof

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

end of thread, other threads:[~2022-03-07 12:13 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-06 17:50 [PATCH 00/26] usb: gadget: remove usage of list iterator past the loop Jakob Koschel
2022-03-06 17:50 ` [PATCH 01/26] usb: gadget: fsl: remove usage of list iterator past the loop body Jakob Koschel
2022-03-06 18:39   ` Linus Torvalds
2022-03-06 19:19     ` Jakob Koschel
2022-03-06 17:50 ` [PATCH 02/26] usb: gadget: bdc: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 03/26] usb: gadget: udc: atmel: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 04/26] usb: gadget: udc: pxa25x: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 05/26] usb: gadget: udc: at91: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 06/26] usb: gadget: goku_udc: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 07/26] usb: gadget: udc: gr_udc: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 08/26] usb: gadget: lpc32xx_udc: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 09/26] usb: gadget: mv_u3d: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 10/26] usb: gadget: udc: mv_udc_core: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 11/26] usb: gadget: net2272: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 12/26] usb: gadget: udc: net2280: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 13/26] usb: gadget: omap_udc: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 14/26] usb: gadget: s3c-hsudc: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 15/26] usb: gadget: udc-xilinx: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 16/26] usb: gadget: aspeed: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 17/26] usb: gadget: configfs: remove using list iterator after loop body as a ptr Jakob Koschel
2022-03-06 17:50 ` [PATCH 18/26] usb: gadget: legacy: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 19/26] usb: gadget: udc: max3420_udc: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 20/26] usb: gadget: tegra-xudc: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 21/26] usb: gadget: composite: remove check of list iterator against head past the loop body Jakob Koschel
2022-03-06 17:50 ` [PATCH 22/26] usb: gadget: pxa27x_udc: replace usage of rc to check if a list element was found Jakob Koschel
2022-03-06 17:50 ` [PATCH 23/26] usb: gadget: udc: s3c2410: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 24/26] usb: gadget: udc: core: " Jakob Koschel
2022-03-06 17:50 ` [PATCH 25/26] usb: gadget: dummy_hcd: " Jakob Koschel
2022-03-06 18:00   ` Greg KH
2022-03-06 19:16     ` Jakob Koschel
2022-03-06 17:50 ` [PATCH 26/26] usb: gadget: udc: s3c2410: " Jakob Koschel
2022-03-07 12:13   ` Krzysztof Kozlowski

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).