Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] drm/kmb: invalid CRTC and mode_config cleanup on kmb_probe() error path [1] --
commit ea7f217c42f68c4024aad8e879735018a1ecdb10 Author: Guangshuo Li <[email protected]> drm/kmb: Fix potential invalid free of plane objects This commit replaces drmm_kzalloc() and drmm_kfree() with kzalloc_obj() and kfree() in kmb_plane_init() so plane allocations match the kfree() in kmb_plane_destroy(). > diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c > index 1742c2c6dfd89..7c908ca23e5ba 100644 > --- a/drivers/gpu/drm/kmb/kmb_plane.c > +++ b/drivers/gpu/drm/kmb/kmb_plane.c > @@ -581,7 +581,7 @@ struct kmb_plane *kmb_plane_init(struct drm_device *drm) > BIT(DRM_MODE_BLEND_COVERAGE); > > for (i = 0; i < KMB_MAX_PLANES; i++) { > - plane = drmm_kzalloc(drm, sizeof(*plane), GFP_KERNEL); > + plane = kzalloc_obj(*plane); > > if (!plane) { > drm_err(drm, "Failed to allocate plane\n"); > @@ -636,6 +636,6 @@ struct kmb_plane *kmb_plane_init(struct drm_device *drm) > > return primary; > cleanup: > - drmm_kfree(drm, plane); > + kfree(plane); > return ERR_PTR(ret); > } [Severity: High] This problem wasn't introduced by this patch, but if kmb_plane_init() or an earlier step in kmb_setup_mode_config() fails, doesn't the err_free path in kmb_probe() still perform invalid CRTC and mode_config cleanup [1]? drivers/gpu/drm/kmb/kmb_drv.c:kmb_probe() { ... ret = kmb_setup_mode_config(&kmb->drm); if (ret) goto err_free; ... err_free: drm_crtc_cleanup(&kmb->crtc); drm_mode_config_cleanup(&kmb->drm); ... } When kmb_setup_mode_config() fails before drm_crtc_init_with_planes() initializes kmb->crtc (for example when kmb_plane_init() returns an error), drm_crtc_cleanup(&kmb->crtc) dereferences an uninitialized crtc->head list entry, causing a NULL pointer dereference. In addition, because kmb_setup_mode_config() uses drmm_mode_config_init(), calling drm_mode_config_cleanup() explicitly at err_free causes it to run a second time when devm_drm_dev_alloc() unwinds. [1] https://sashiko.dev/#/bug/linux-d222f5e7-17ec-4c5d-8774-adf4a0718282 -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
