In the Linux kernel, the following vulnerability has been resolved:
drm/amd/display: use proper context for logging
The same as the rest of the code, getssinfofromatombios() uses calcpllcs->ctx->logger for logging. But calcpllcs->ctx is initialized only later in calcpllmaxvcoconstruct(). Therefore, any output using DCLOGSYNC() leads to a NULL pointer deference in getssinfofromatombios().
According to Sashiko, the very same problem exists in dce112getpixclkdividers() and dcn3getpixclkdividers() too.
To avoid accessing the NULL context, use clksrc->base.ctx->logger everywhere. That context in base is initialized earlier in dce110clksrcconstruct() and dce112clksrcconstruct(). Before getssinfofromatombios() or Sashiko's getpixclkdividers functions above are actually called. This is done by redefining DC_LOGGER to CTX->logger.
Before: dce110clksrcconstruct() did: -> sets clksrc->base.ctx = ctx; -> ssinfofromatombioscreate() -> getssinfofromatombios() <- uses calcpllcs->ctx # BOOM -> calcpllmaxvcoconstruct() <- sets calcpllcs->ctx
After: dce110clksrcconstruct() does: -> sets clksrc->base.ctx = ctx; -> ssinfofromatombioscreate() -> getssinfofromatombios() <- uses clk_src->base.ctx
(cherry picked from commit 6f16fcbb0c46a87e3d9685407e906573d60104b0)