Re: [PATCH 2/2] drm/nouveau/clk: avoid usage of list iterator after loop

2023-03-07 Thread Lyude Paul
On Wed, 2023-03-01 at 18:25 +0100, Jakob Koschel wrote: > + } >   } >   > + BUG_ON(!pstate); >   nvkm_debug(subdev, "setting performance state %d\n", pstatei); >   clk->pstate = pstatei; We should probably also replace this with if (WARN_ON(!pstate)

[PATCH 2/2] drm/nouveau/clk: avoid usage of list iterator after loop

2023-03-02 Thread Jakob Koschel
If potentially no valid element is found, 'pstate' would contain an invalid pointer past the iterator loop. To ensure 'pstate' is always valid, we only set it if the correct element was found. That allows adding a BUG_ON in case the code works incorrectly, exposing currently undetectable potential