nouveau.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [Nouveau] [PATCH v2 0/2] drm/nouveau: avoid usage of list iterator after loop
@ 2023-03-13 13:54 Jakob Koschel
  2023-03-13 13:54 ` [Nouveau] [PATCH v2 1/2] drm/nouveau/device: " Jakob Koschel
  2023-03-13 13:54 ` [Nouveau] [PATCH v2 2/2] drm/nouveau/clk: " Jakob Koschel
  0 siblings, 2 replies; 3+ messages in thread
From: Jakob Koschel @ 2023-03-13 13:54 UTC (permalink / raw)
  To: Ben Skeggs, Karol Herbst, Lyude Paul, David Airlie, Daniel Vetter
  Cc: nouveau, Pietro Borrello, linux-kernel, dri-devel,
	Cristiano Giuffrida, Bos, H.J.,
	Jakob Koschel

This patch set includes two instances where the list iterator variable
'pstate' is implicitly assumed to be valid after the iterator loop.
While in pratice that is most likely the case (if
'pstatei'/'args->v0.state' is <= the elements in clk->states), we should
explicitly only allow 'pstate' to always point to correct 'nvkm_pstate'
structs.

That allows catching potential bugs with WARN_ON(!pstate) that otherwise
would be completely undetectable.

It also helps the greater mission to hopefully move the list iterator
variable into the iterating macro directly [1].

Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
Signed-off-by: Jakob Koschel <jkl820.git@gmail.com>
---
Changes in v2:
- convert BUG_ON() into WARN_ON()
- Link to v1: https://lore.kernel.org/r/20230301-drm-nouveau-avoid-iter-after-loop-v1-0-0702ec23f970@gmail.com

---
Jakob Koschel (2):
      drm/nouveau/device: avoid usage of list iterator after loop
      drm/nouveau/clk: avoid usage of list iterator after loop

 drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c | 11 ++++++++---
 drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c    | 10 +++++++---
 2 files changed, 15 insertions(+), 6 deletions(-)
---
base-commit: c0927a7a5391f7d8e593e5e50ead7505a23cadf9
change-id: 20230301-drm-nouveau-avoid-iter-after-loop-4bff97166efa

Best regards,
-- 
Jakob Koschel <jkl820.git@gmail.com>


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

end of thread, other threads:[~2023-05-04 12:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 13:54 [Nouveau] [PATCH v2 0/2] drm/nouveau: avoid usage of list iterator after loop Jakob Koschel
2023-03-13 13:54 ` [Nouveau] [PATCH v2 1/2] drm/nouveau/device: " Jakob Koschel
2023-03-13 13:54 ` [Nouveau] [PATCH v2 2/2] drm/nouveau/clk: " Jakob Koschel

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