Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm/mode-config: NULL deref of mode_config.funcs in drm_mode_config_create_initial_state() - [Low] drm/mode-config: commit message function name mismatch and unused header --
commit de65a82f52b624078e630d3146fcef76dfc9518c Author: Maxime Ripard <[email protected]> > drm/mode-config: Read out hardware state in drm_mode_config_create_state > > drm_mode_config_create_state() creates the initial state for all > KMS objects at driver registration time. > > Call the drm_mode_config_funcs.atomic_sro_readout_state hook from it > so that the initial state is populated from the hardware rather than > being left as a pristine default. > > Reviewed-by: Maarten Lankhorst <[email protected]> > Signed-off-by: Maxime Ripard <[email protected]> > --- > drivers/gpu/drm/drm_mode_config.c | 70 ++++++++++++++++++++++++++++++--------- > 1 file changed, 55 insertions(+), 15 deletions(-) > > diff --git a/drivers/gpu/drm/drm_mode_config.c > b/drivers/gpu/drm/drm_mode_config.c > index c1e993a78702e..9f242e2654c82 100644 > --- a/drivers/gpu/drm/drm_mode_config.c > +++ b/drivers/gpu/drm/drm_mode_config.c > @@ -24,6 +24,7 @@ > #include <linux/uaccess.h> > > #include <drm/drm_atomic.h> > +#include <drm/drm_atomic_state_readout.h> [Severity: Low] This isn't a bug, but the commit subject and message refer to drm_mode_config_create_state(), whereas the patch renames the fallback allocator to a static drm_mode_config_create_state() helper and calls atomic_sro_readout_state under modeset locks in the exported drm_mode_config_create_initial_state(). Also, nothing in this file uses <drm/drm_atomic_state_readout.h>. [ ... ] > @@ -408,6 +396,58 @@ int drm_mode_config_create_initial_state(struct > drm_device *dev) > > return 0; > } > + [ ... ] > +int drm_mode_config_create_initial_state(struct drm_device *dev) > +{ > + struct drm_modeset_acquire_ctx ctx; > + int ret; > + > + /* > + * The initial state is usually created while the device is > + * being initialized and nothing can access it concurrently, > + * but holding all the modeset locks puts the readout, the > + * installation of its result and the creation of the pristine > + * states under the same locking contract as the regular > + * atomic paths. > + */ > + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); > + > + if (dev->mode_config.funcs->atomic_sro_readout_state) { > + ret = dev->mode_config.funcs->atomic_sro_readout_state(dev); > + if (!ret) > + goto out; > + } [Severity: High] Can this cause a NULL pointer dereference on dev->mode_config.funcs? Previously, drm_mode_config_create_initial_state() did not dereference dev->mode_config.funcs, and some drivers call it before setting that pointer: drivers/gpu/drm/sun4i/sun4i_framebuffer.c:sun4i_framebuffer_init() { ... drm_WARN(drm, drm_mode_config_create_initial_state(drm), "Failed to create state\n"); drm->mode_config.max_width = 8192; drm->mode_config.max_height = 8192; drm->mode_config.normalize_zpos = true; drm->mode_config.funcs = &sun4i_de_mode_config_funcs; ... } When sun4i (or shmob_drm_modeset_init()) probes, dev->mode_config.funcs is still NULL here, causing an immediate NULL pointer dereference. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=19
