lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAOTY__d2A6BiegTqX+eXAk5LYAtRexnwLvkbje94ax05jOMug@mail.gmail.com>
Date: Wed, 19 Feb 2025 22:01:30 +0800
From: Chun-Kuang Hu <chunkuang.hu@...nel.org>
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
Cc: chunkuang.hu@...nel.org, p.zabel@...gutronix.de, airlied@...il.com, 
	simona@...ll.ch, maarten.lankhorst@...ux.intel.com, mripard@...nel.org, 
	tzimmermann@...e.de, robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org, 
	matthias.bgg@...il.com, ck.hu@...iatek.com, jitao.shi@...iatek.com, 
	jie.qiu@...iatek.com, junzhi.zhao@...iatek.com, 
	dri-devel@...ts.freedesktop.org, linux-mediatek@...ts.infradead.org, 
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-arm-kernel@...ts.infradead.org, kernel@...labora.com, 
	dmitry.baryshkov@...aro.org, lewis.liao@...iatek.com, 
	ives.chenjh@...iatek.com, tommyyl.chen@...iatek.com, 
	jason-jh.lin@...iatek.com
Subject: Re: [PATCH v7 17/43] drm/mediatek: mtk_hdmi: Unregister audio
 platform device on failure

Hi, Angelo:

AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com> 於
2025年2月17日 週一 下午11:49寫道:
>
> The probe function of this driver may fail after registering the
> audio platform device: in that case, the state is not getting
> cleaned up, leaving this device registered.
>
> Adding up to the mix, should the probe function of this driver
> return a probe deferral for N times, we're registering up to N
> audio platform devices and, again, never freeing them up.
>
> To fix this, add a pointer to the audio platform device in the
> mtk_hdmi structure, and add a devm action to unregister it upon
> driver removal or probe failure.

Applied to mediatek-drm-next [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

>
> Fixes: 8f83f26891e1 ("drm/mediatek: Add HDMI support")
> Reviewed-by: CK Hu <ck.hu@...iatek.com>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_hdmi.c | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> index be71105ba81d..b9f4f06edde6 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> @@ -172,6 +172,7 @@ struct mtk_hdmi {
>         unsigned int sys_offset;
>         void __iomem *regs;
>         enum hdmi_colorspace csp;
> +       struct platform_device *audio_pdev;
>         struct hdmi_audio_param aud_param;
>         bool audio_enable;
>         bool powered;
> @@ -1661,6 +1662,11 @@ static const struct hdmi_codec_ops mtk_hdmi_audio_codec_ops = {
>         .hook_plugged_cb = mtk_hdmi_audio_hook_plugged_cb,
>  };
>
> +static void mtk_hdmi_unregister_audio_driver(void *data)
> +{
> +       platform_device_unregister(data);
> +}
> +
>  static int mtk_hdmi_register_audio_driver(struct device *dev)
>  {
>         struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
> @@ -1671,13 +1677,20 @@ static int mtk_hdmi_register_audio_driver(struct device *dev)
>                 .data = hdmi,
>                 .no_capture_mute = 1,
>         };
> -       struct platform_device *pdev;
> +       int ret;
>
> -       pdev = platform_device_register_data(dev, HDMI_CODEC_DRV_NAME,
> -                                            PLATFORM_DEVID_AUTO, &codec_data,
> -                                            sizeof(codec_data));
> -       if (IS_ERR(pdev))
> -               return PTR_ERR(pdev);
> +       hdmi->audio_pdev = platform_device_register_data(dev,
> +                                                        HDMI_CODEC_DRV_NAME,
> +                                                        PLATFORM_DEVID_AUTO,
> +                                                        &codec_data,
> +                                                        sizeof(codec_data));
> +       if (IS_ERR(hdmi->audio_pdev))
> +               return PTR_ERR(hdmi->audio_pdev);
> +
> +       ret = devm_add_action_or_reset(dev, mtk_hdmi_unregister_audio_driver,
> +                                      hdmi->audio_pdev);
> +       if (ret)
> +               return ret;
>
>         DRM_INFO("%s driver bound to HDMI\n", HDMI_CODEC_DRV_NAME);
>         return 0;
> --
> 2.48.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ