[PATCH] drm/i915/gt: Prevent uninitialized pointer reads
Krzysztof Karas
krzysztof.karas at intel.com
Mon Dec 30 14:24:45 UTC 2024
Hi Apoorva and Andi,
> > Initialize rq to NULL to prevent uninitialized pointer reads.
>
> where is it happening?
>
> Andi
There are two instances that I see:
1) err = fn(..., &rq); <- this probably will set the rq (at least
looking at the functions that are used to set "fn", when calling
"clear()"), but from the clear()'s execution perspective there are
no guarantees that this value will be initialized.
2) If an "err" is set and detected before "rq" is initialized, then
there is a path that the execution might take that leads to reading
uninitialized "rq":
if all calls to i915_gem_object_pin_map() would result in -ENXIO,
then the loop would exit with a "continue" and err = -ENXIO. This then
triggers "if (err)" after the loop and takes the second "if", which
starts by checking the value of "rq", which at this point would still
be uninitialized.
I think this initialization removes these corner cases, so it is worth
introducing.
Krzysztof
More information about the Intel-gfx
mailing list