]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
drm/msm: Avoid NULL dereference in msm_disp_state_print_regs()
authorDouglas Anderson <dianders@chromium.org>
Mon, 14 Oct 2024 16:36:08 +0000 (09:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Nov 2024 00:52:33 +0000 (01:52 +0100)
commit42cf045086feae77b212f0f66e742b91a5b566b7
tree6aae684d3e383055b01042891fbf0db6a77eac04
parentd125fbf1e128dd759e51f2ce8ab0f0d8aa66fe4c
drm/msm: Avoid NULL dereference in msm_disp_state_print_regs()

[ Upstream commit 293f53263266bc4340d777268ab4328a97f041fa ]

If the allocation in msm_disp_state_dump_regs() failed then
`block->state` can be NULL. The msm_disp_state_print_regs() function
_does_ have code to try to handle it with:

  if (*reg)
    dump_addr = *reg;

...but since "dump_addr" is initialized to NULL the above is actually
a noop. The code then goes on to dereference `dump_addr`.

Make the function print "Registers not stored" when it sees a NULL to
solve this. Since we're touching the code, fix
msm_disp_state_print_regs() not to pointlessly take a double-pointer
and properly mark the pointer as `const`.

Fixes: 98659487b845 ("drm/msm: add support to take dpu snapshot")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/619657/
Link: https://lore.kernel.org/r/20241014093605.1.Ia1217cecec9ef09eb3c6d125360cc6c8574b0e73@changeid
Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c