mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "Peng Liu (刘鹏)" <Peng.Liu@mediatek.com>,
	"Mac Shen (沈俊)" <Mac.Shen@mediatek.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
	"simona@ffwll.ch" <simona@ffwll.ch>,
	"Jitao Shi (石记涛)" <jitao.shi@mediatek.com>,
	"LIANKUN YANG (杨连坤)" <Liankun.Yang@mediatek.com>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"granquet@baylibre.com" <granquet@baylibre.com>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"msp@baylibre.com" <msp@baylibre.com>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"Rex-BC Chen (陳柏辰)" <Rex-BC.Chen@mediatek.com>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>
Cc: "dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>
Subject: Re: [PATCH v2 1/1] drm/mediatek: Fix potential KP on 0 bytes nvmem cell read
Date: Wed, 23 Oct 2024 05:15:22 +0000	[thread overview]
Message-ID: <5445a85890e411c02a69a2a8608779abb84a5ce4.camel@mediatek.com> (raw)
In-Reply-To: <20240927153305.27642-1-liankun.yang@mediatek.com>

Hi, Liankun:

On Fri, 2024-09-27 at 17:03 +0800, Liankun Yang wrote:
> If the len is 0, kernel crash will occur when performing operations.
> Add the len check conditions to prevent kernel crash.
> 
> Fixes: f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")
> Signed-off-by: Liankun Yang <liankun.yang@mediatek.com>
> ---
> Changes in V2:
> - Fix the commit title.
> - Remove blank line between the Fixes and Signe-off-by.
> - Modify the judgment writing method.
> Per suggestion from the previous thread:
> https://patchwork.kernel.org/project/linux-mediatek/patch/20240925084116.28848-1-liankun.yang@mediatek.com/
> ---
>  drivers/gpu/drm/mediatek/mtk_dp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
> index d8796a904eca..9ecdf62398ee 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
> @@ -1082,7 +1082,7 @@ static void mtk_dp_get_calibration_data(struct mtk_dp *mtk_dp)
>  	buf = (u32 *)nvmem_cell_read(cell, &len);
>  	nvmem_cell_put(cell);
>  
> -	if (IS_ERR(buf) || ((len / sizeof(u32)) != 4)) {

In original code, when len = 0, no kernel panic occur.
Nacked by me.

Regards,
CK


> +	if (IS_ERR(buf) || !len || ((len / sizeof(u32)) != 4)) {
>  		dev_warn(dev, "Failed to read nvmem_cell_read\n");
>  
>  		if (!IS_ERR(buf))

      parent reply	other threads:[~2024-10-23  5:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27  9:03 Liankun Yang
2024-10-09 15:41 ` Guillaume Ranquet
2024-10-28 13:18   ` LIANKUN YANG (杨连坤)
2024-10-23  5:15 ` CK Hu (胡俊光) [this message]

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=5445a85890e411c02a69a2a8608779abb84a5ce4.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Liankun.Yang@mediatek.com \
    --cc=Mac.Shen@mediatek.com \
    --cc=Peng.Liu@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Rex-BC.Chen@mediatek.com \
    --cc=airlied@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=granquet@baylibre.com \
    --cc=jitao.shi@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=msp@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    --cc=simona@ffwll.ch \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®