From: sashiko-bot@kernel.org
To: "Diogo Silva" <diogompaissilva@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/rockchip: dsi: Open-code drm_simple_encoder_init()
Date: Sun, 07 Jun 2026 12:48:59 +0000 [thread overview]
Message-ID: <20260607124900.0C1041F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260607123739.393974-2-diogompaissilva@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The return value of `drm_encoder_init()` is ignored, which can lead to a NULL pointer dereference on subsequent error cleanup paths.
--
commit 386dea7155c8b56dde923c52be1155ed455ebd09
Author: Diogo Silva <diogompaissilva@gmail.com>
drm/rockchip: dsi: Open-code drm_simple_encoder_init()
This patch removes the dependency on the deprecated simple KMS helper from
rockchip DRM drivers by inlining drm_simple_encoder_init into the drivers.
[ ... ]
> diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
[ ... ]
> @@ -604,7 +607,8 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
> }
>
> drm_encoder_helper_add(encoder, &dw_hdmi_rockchip_encoder_helper_funcs);
> - drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);
> + drm_encoder_init(drm, encoder, &dw_hdmi_rockchip_encoder_funcs,
> + DRM_MODE_ENCODER_TMDS, NULL);
[Severity: High]
This isn't a bug introduced by this patch, but does the return value of
drm_encoder_init() need to be checked here?
If drm_encoder_init() fails, encoder->dev remains NULL. If the subsequent
dw_hdmi_bind() call fails, the error path jumps to err_bind and calls
drm_encoder_cleanup(encoder). This explicitly dereferences encoder->dev
inside drm_mode_object_unregister(), which would cause a NULL pointer
dereference.
[ ... ]
> diff --git a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
> --- a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
> +++ b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
[ ... ]
> @@ -586,7 +589,8 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,
> return ret;
>
> drm_encoder_helper_add(encoder, &dw_hdmi_qp_rockchip_encoder_helper_funcs);
> - drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);
> + drm_encoder_init(drm, encoder, &dw_hdmi_qp_rockchip_encoder_funcs,
> + DRM_MODE_ENCODER_TMDS, NULL);
[Severity: High]
This is a pre-existing issue, but should this code check the return value of
drm_encoder_init() for errors?
Similar to the previous file, if this initialization fails and leaves
encoder->dev as NULL, a subsequent failure in dw_hdmi_qp_bind() triggers
an error path that explicitly calls drm_encoder_cleanup(encoder), leading
to a NULL pointer dereference.
[ ... ]
> diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
> --- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c
> +++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
[ ... ]
> @@ -696,7 +699,8 @@ rk3066_hdmi_register(struct drm_device *drm, struct rk3066_hdmi *hdmi)
> return -EPROBE_DEFER;
>
> drm_encoder_helper_add(encoder, &rk3066_hdmi_encoder_helper_funcs);
> - drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);
> + drm_encoder_init(drm, encoder, &rk3066_hdmi_encoder_funcs,
> + DRM_MODE_ENCODER_TMDS, NULL);
[Severity: High]
This is a pre-existing issue, but what happens if drm_encoder_init() fails
here?
If it fails and a subsequent initialization step fails, the error cleanup will
call the encoder's destroy function, causing a NULL pointer dereference since
encoder->dev would be NULL.
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260607123739.393974-2-diogompaissilva@gmail.com?part=1
next prev parent reply other threads:[~2026-06-07 12:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 12:32 [PATCH] drm/rockchip: dsi: Open-code drm_simple_encoder_init() Diogo Silva
2026-06-04 12:32 ` Diogo Silva
2026-06-07 10:59 ` Heiko Stuebner
2026-06-07 10:59 ` Heiko Stuebner
2026-06-07 11:00 ` Heiko Stuebner
2026-06-07 11:00 ` Heiko Stuebner
2026-06-07 11:57 ` Diogo Silva
2026-06-07 11:57 ` Diogo Silva
2026-06-07 12:37 ` [PATCH v2] " Diogo Silva
2026-06-07 12:37 ` Diogo Silva
2026-06-07 12:48 ` sashiko-bot [this message]
2026-06-07 17:01 ` Jonas Karlman
2026-06-07 17:01 ` Jonas Karlman
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=20260607124900.0C1041F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=diogompaissilva@gmail.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.