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] [day] [month] [year] [list]
Message-ID: <799c9d76cd847dbeed7e414e6504719d8da8bd06.camel@mediatek.com>
Date: Wed, 19 Nov 2025 06:57:26 +0000
From: CK Hu (胡俊光) <ck.hu@...iatek.com>
To: "zhang.enpei@....com.cn" <zhang.enpei@....com.cn>,
	"chunkuang.hu@...nel.org" <chunkuang.hu@...nel.org>
CC: "simona@...ll.ch" <simona@...ll.ch>, "dri-devel@...ts.freedesktop.org"
	<dri-devel@...ts.freedesktop.org>, AngeloGioacchino Del Regno
	<angelogioacchino.delregno@...labora.com>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "airlied@...il.com" <airlied@...il.com>,
	"linux-arm-kernel@...ts.infradead.org"
	<linux-arm-kernel@...ts.infradead.org>, "p.zabel@...gutronix.de"
	<p.zabel@...gutronix.de>, "matthias.bgg@...il.com" <matthias.bgg@...il.com>,
	"linux-mediatek@...ts.infradead.org" <linux-mediatek@...ts.infradead.org>
Subject: Re: [PATCH] drm/mediatek: mtk_drm_drv: switch to use
 devm_kmemdup_array()

On Tue, 2025-08-19 at 17:25 +0800, zhang.enpei@....com.cn wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
> 
> 
> From: Zhang Enpei <zhang.enpei@....com.cn>
> 
> Use devm_kmemdup_array() to avoid multiplication or possible overflows.
> 
> Signed-off-by: Zhang Enpei <zhang.enpei@....com.cn>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index d5e6bab36414..e700c0f0a3a2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -1003,7 +1003,8 @@ static int mtk_drm_of_ddp_path_build_one(struct device *dev, enum mtk_crtc_path
>                 return -EINVAL;
>         }
> 
> -       final_ddp_path = devm_kmemdup(dev, temp_path, idx * sizeof(temp_path[0]), GFP_KERNEL);
> +       final_ddp_path = devm_kmemdup_array(dev, temp_path, idx,
> +                                           sizeof(*temp_path), GFP_KERNEL);

idx and sizeof(*temp_path) are so small, it's not necessary to worry overflow.
devm_kmemdup_array() would use built-in multiply, it's also a multiplication.

Regards,
CK

>         if (!final_ddp_path)
>                 return -ENOMEM;
> 
> --
> 2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ