All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "John Harrison" <John.Harrison@Igalia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 4/8] drm/komeda: use drmm_writeback_connector_init()
Date: Thu, 23 Jul 2026 01:02:21 +0000	[thread overview]
Message-ID: <20260723010221.AC4001F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723003205.330362-5-John.Harrison@Igalia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Manual call to `drm_mode_config_cleanup()` during driver teardown causes NULL pointer dereferences on drmm-managed encoder and connector.
--

--- Patch [4]: [PATCH v8 4/8] drm/komeda: use drmm_writeback_connector_init() ---
commit 252267d60505e182c9ac4aa8fed48741764eeb23
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

    drm/komeda: use drmm_writeback_connector_init()
    
    The driver uses drm_writeback_connector_init() instead of its drmm
    counterpart, but it doesn't perform the job queue cleanup (neither
    manually nor by calling drm_writeback_connector_cleanup()). On the
    contrary, the drmm_writeback_connector_init() function ensures the
    proper cleanup of the job queue.
    
    Use drmm_plain_encoder_alloc() to allocate simple encoder and
    drmm_writeback_connector_init() in order to initialize writeback
    connector instance.

> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> index 41cc3e080dc9c..65f072cfe42f9 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c

[ ... ]

> @@ -121,17 +122,10 @@ komeda_wb_connector_fill_modes(struct drm_connector *connector,
>  	return 0;
>  }
>  
> -static void komeda_wb_connector_destroy(struct drm_connector *connector)
> -{
> -	drm_connector_cleanup(connector);
> -	kfree(to_kconn(to_wb_conn(connector)));
> -}
> -
>  static const struct drm_connector_funcs komeda_wb_connector_funcs = {
>  	.reset			= drm_atomic_helper_connector_reset,
>  	.detect			= komeda_wb_connector_detect,
>  	.fill_modes		= komeda_wb_connector_fill_modes,
> -	.destroy		= komeda_wb_connector_destroy,
>  	.atomic_duplicate_state	= drm_atomic_helper_connector_duplicate_state,
>  	.atomic_destroy_state	= drm_atomic_helper_connector_destroy_state,
>  };

[ ... ]

> @@ -161,20 +157,29 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
>  					       kwb_conn->wb_layer->layer_type,
>  					       &n_formats);
>  	if (!formats) {
> -		kfree(kwb_conn);
> +		drmm_kfree(&kms->base, kwb_conn);
>  		return -ENOMEM;
>  	}
>  
> -	err = drm_writeback_connector_init(&kms->base, wb_conn,
> -					   &komeda_wb_connector_funcs,
> -					   &komeda_wb_encoder_helper_funcs,
> -					   formats, n_formats,
> -					   BIT(drm_crtc_index(&kcrtc->base)));
> +	encoder = drmm_plain_encoder_alloc(&kms->base, NULL,
> +					   DRM_MODE_ENCODER_VIRTUAL, NULL);

[Severity: High]
Will this crash during driver teardown or initialization failure?

The komeda driver still explicitly calls drm_mode_config_cleanup() during its
teardown in komeda_kms_detach() and in the error path of komeda_kms_attach():

komeda_kms_attach() {
    ...
cleanup_mode_config:
	drm_mode_config_cleanup(drm);
    ...
}

Because drm_mode_config_cleanup() unconditionally invokes the .destroy hook
for all encoders and connectors, and drmm_plain_encoder_alloc() is called
here with a NULL funcs pointer, will the cleanup attempt to dereference a
NULL funcs pointer (encoder->funcs->destroy)? 

Similarly, the .destroy hook has been removed from komeda_wb_connector_funcs
above, so will drm_mode_config_cleanup() also crash when attempting to call
connector->funcs->destroy()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260723003205.330362-1-John.Harrison@Igalia.com?part=4

  reply	other threads:[~2026-07-23  1:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  0:31 [PATCH v8 0/8] drm: writeback: clean up writeback connector initialization John Harrison
2026-07-23  0:31 ` [PATCH v8 1/8] drm/managed: implement managed versions of kzalloc_obj/objs() John Harrison
2026-07-23  0:31 ` [PATCH v8 2/8] drm/amd/display: use drmm allocation for writeback connector John Harrison
2026-07-23  0:54   ` sashiko-bot
2026-07-23  0:31 ` [PATCH v8 3/8] drm/amd/display: use drmm_writeback_connector_init() John Harrison
2026-07-23  0:53   ` sashiko-bot
2026-07-23  0:31 ` [PATCH v8 4/8] drm/komeda: " John Harrison
2026-07-23  1:02   ` sashiko-bot [this message]
2026-07-23  0:32 ` [PATCH v8 5/8] drm/mali: " John Harrison
2026-07-23  0:32 ` [PATCH v8 6/8] drm: renesas: rcar-du: " John Harrison
2026-07-23  0:32 ` [PATCH v8 7/8] drm/vc4: " John Harrison
2026-07-23  0:53   ` sashiko-bot
2026-07-23  0:32 ` [PATCH v8 8/8] drm: writeback: drop excess connector initialization functions John Harrison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260723010221.AC4001F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=John.Harrison@Igalia.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.