From: Jakob Koschel <jakobkoschel@gmail.com>
To: Greg Kroah-Hartman <greg@kroah.com>
Cc: Jakob Koschel <jakobkoschel@gmail.com>,
linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Felipe Balbi <balbi@kernel.org>, Joel Stanley <joel@jms.id.au>,
Andrew Jeffery <andrew@aj.id.au>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Beznea <claudiu.beznea@microchip.com>,
Cristian Birsan <cristian.birsan@microchip.com>,
Al Cooper <alcooperx@gmail.com>, Li Yang <leoyang.li@nxp.com>,
Vladimir Zapolskiy <vz@mleia.com>,
Daniel Mack <daniel@zonque.org>,
Haojian Zhuang <haojian.zhuang@gmail.com>,
Robert Jarzmik <robert.jarzmik@free.fr>,
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Michal Simek <michal.simek@xilinx.com>,
linux-usb@vger.kernel.org (open list:USB GADGET/PERIPHERAL
SUBSYSTEM), Mike Rapoport <rppt@kernel.org>,
"Brian Johannesmeyer" <bjohannesmeyer@gmail.com>,
Cristiano Giuffrida <c.giuffrida@vu.nl>,
"Bos, H.J." <h.j.bos@vu.nl>
Subject: [PATCH v2 00/26] usb: gadget: remove usage of list iterator past the loop
Date: Tue, 8 Mar 2022 18:17:52 +0100 [thread overview]
Message-ID: <20220308171818.384491-1-jakobkoschel@gmail.com> (raw)
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
Change since v1:
- renamed list iterator variable from 'tmp' to 'iter' (Linus)
- inverted the conditions within the loop (Linus)
- reverted the check on 'rc' after the loop (Greg & Krzysztof)
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: composite: remove usage of list iterator past the loop
body
usb: gadget: udc: core: remove usage of list iterator past the loop
body
usb: gadget: dummy_hcd: remove usage of list iterator past the loop
body
usb: gadget: udc: s3c2410: remove usage of list iterator past the loop
body
drivers/usb/gadget/composite.c | 36 +++++++++++++-----------
drivers/usb/gadget/configfs.c | 24 +++++++++-------
drivers/usb/gadget/legacy/hid.c | 23 +++++++--------
drivers/usb/gadget/udc/aspeed-vhub/epn.c | 12 ++++----
drivers/usb/gadget/udc/at91_udc.c | 12 ++++----
drivers/usb/gadget/udc/atmel_usba_udc.c | 13 +++++----
drivers/usb/gadget/udc/bdc/bdc_ep.c | 13 ++++++---
drivers/usb/gadget/udc/core.c | 20 +++++++------
drivers/usb/gadget/udc/dummy_hcd.c | 17 +++++------
drivers/usb/gadget/udc/fsl_qe_udc.c | 13 +++++----
drivers/usb/gadget/udc/fsl_udc_core.c | 13 +++++----
drivers/usb/gadget/udc/goku_udc.c | 12 ++++----
drivers/usb/gadget/udc/gr_udc.c | 12 ++++----
drivers/usb/gadget/udc/lpc32xx_udc.c | 12 ++++----
drivers/usb/gadget/udc/max3420_udc.c | 18 +++++++-----
drivers/usb/gadget/udc/mv_u3d_core.c | 12 ++++----
drivers/usb/gadget/udc/mv_udc_core.c | 12 ++++----
drivers/usb/gadget/udc/net2272.c | 13 +++++----
drivers/usb/gadget/udc/net2280.c | 13 +++++----
drivers/usb/gadget/udc/omap_udc.c | 12 ++++----
drivers/usb/gadget/udc/pxa25x_udc.c | 13 +++++----
drivers/usb/gadget/udc/pxa27x_udc.c | 13 +++++----
drivers/usb/gadget/udc/s3c-hsudc.c | 12 ++++----
drivers/usb/gadget/udc/s3c2410_udc.c | 17 +++++------
drivers/usb/gadget/udc/tegra-xudc.c | 12 ++++----
drivers/usb/gadget/udc/udc-xilinx.c | 13 +++++----
26 files changed, 227 insertions(+), 165 deletions(-)
base-commit: 719fce7539cd3e186598e2aed36325fe892150cf
--
2.25.1
next reply other threads:[~2022-03-08 17:20 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-08 17:17 Jakob Koschel [this message]
2022-03-08 17:17 ` [PATCH v2 01/26] usb: gadget: fsl: remove usage of list iterator past the loop body Jakob Koschel
2022-03-08 17:17 ` [PATCH v2 02/26] usb: gadget: bdc: " Jakob Koschel
2022-03-08 17:17 ` [PATCH v2 03/26] usb: gadget: udc: atmel: " Jakob Koschel
2022-03-08 17:17 ` [PATCH v2 04/26] usb: gadget: udc: pxa25x: " Jakob Koschel
2022-03-08 17:17 ` [PATCH v2 05/26] usb: gadget: udc: at91: " Jakob Koschel
2022-03-08 17:17 ` [PATCH v2 06/26] usb: gadget: goku_udc: " Jakob Koschel
2022-03-08 17:17 ` [PATCH v2 07/26] usb: gadget: udc: gr_udc: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 08/26] usb: gadget: lpc32xx_udc: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 09/26] usb: gadget: mv_u3d: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 10/26] usb: gadget: udc: mv_udc_core: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 11/26] usb: gadget: net2272: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 12/26] usb: gadget: udc: net2280: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 13/26] usb: gadget: omap_udc: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 14/26] usb: gadget: s3c-hsudc: " Jakob Koschel
2022-03-09 17:25 ` Krzysztof Kozlowski
2022-03-09 17:36 ` Jakob Koschel
2022-03-09 17:56 ` Krzysztof Kozlowski
2022-03-08 17:18 ` [PATCH v2 15/26] usb: gadget: udc-xilinx: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 16/26] usb: gadget: aspeed: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 17/26] usb: gadget: configfs: remove using list iterator after loop body as a ptr Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 18/26] usb: gadget: legacy: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 19/26] usb: gadget: udc: max3420_udc: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 20/26] usb: gadget: tegra-xudc: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 21/26] usb: gadget: composite: remove check of list iterator against head past the loop body Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 22/26] usb: gadget: pxa27x_udc: replace usage of rc to check if a list element was found Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 23/26] usb: gadget: composite: remove usage of list iterator past the loop body Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 24/26] usb: gadget: udc: core: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 25/26] usb: gadget: dummy_hcd: " Jakob Koschel
2022-03-08 17:18 ` [PATCH v2 26/26] usb: gadget: udc: s3c2410: " Jakob Koschel
2022-03-09 17:20 ` Krzysztof Kozlowski
2022-03-08 21:17 ` [PATCH v2 00/26] usb: gadget: remove usage of list iterator past the loop Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220308171818.384491-1-jakobkoschel@gmail.com \
--to=jakobkoschel@gmail.com \
--cc=alcooperx@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alim.akhtar@samsung.com \
--cc=andrew@aj.id.au \
--cc=balbi@kernel.org \
--cc=bjohannesmeyer@gmail.com \
--cc=c.giuffrida@vu.nl \
--cc=claudiu.beznea@microchip.com \
--cc=cristian.birsan@microchip.com \
--cc=daniel@zonque.org \
--cc=greg@kroah.com \
--cc=h.j.bos@vu.nl \
--cc=haojian.zhuang@gmail.com \
--cc=joel@jms.id.au \
--cc=jonathanh@nvidia.com \
--cc=krzysztof.kozlowski@canonical.com \
--cc=leoyang.li@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=nicolas.ferre@microchip.com \
--cc=robert.jarzmik@free.fr \
--cc=rppt@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=torvalds@linux-foundation.org \
--cc=vz@mleia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®