All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: "Li, Roman" <Roman.Li@amd.com>
Cc: "SHANMUGAM, SRINIVASAN" <SRINIVASAN.SHANMUGAM@amd.com>,
	"Hung, Alex" <Alex.Hung@amd.com>,
	"Pillai, Aurabindo" <Aurabindo.Pillai@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"Wentland, Harry" <Harry.Wentland@amd.com>,
	Mario Limonciello <superm1@kernel.org>,
	"Chung, ChiaHsuan (Tom)" <ChiaHsuan.Chung@amd.com>
Subject: Re: [PATCH] drm/amd/display: Fix out-of-bounds stream encoder index
Date: Tue, 10 Feb 2026 09:59:27 +0300	[thread overview]
Message-ID: <aYrXTyT6G2u--dFJ@stanley.mountain> (raw)
In-Reply-To: <CY8PR12MB8193570B0F1446F4E65B346E8965A@CY8PR12MB8193.namprd12.prod.outlook.com>

On Mon, Feb 09, 2026 at 11:34:08PM +0000, Li, Roman wrote:
> > diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
> > b/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
> > index 4e962f522f1b..d8c1f1911c37 100644
> > --- a/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
> > +++ b/drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
> > @@ -1230,12 +1230,12 @@ static struct stream_encoder
> > *dcn315_stream_encoder_create(
> >       /*PHYB is wired off in HW, allow front end to remapping, otherwise needs
> > more changes*/
> >
> >       /* Mapping of VPG, AFMT, DME register blocks to DIO block instance */
> > -     if (eng_id <= ENGINE_ID_DIGF) {
> > -             vpg_inst = eng_id;
> > -             afmt_inst = eng_id;
> > -     } else
> > +     if ((unsigned int)eng_id >= ARRAY_SIZE(stream_enc_regs))
> 
> Could you replace the unsigned cast with an explicit bounds check, i.e.
> if (eng_id < 0 || eng_id >= ARRAY_SIZE(stream_enc_regs)) return NULL;
> It would be clearer about what values are being rejected.
> 

Also ARRAY_SIZE() is type size_t so type promotion would mean that it
was already cast to unsigned long.  Casting it to "unsigned int" makes
me itch because u32 is smaller than ulong normally.

regards,
dan carpenter


      reply	other threads:[~2026-02-10  8:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06 15:19 [PATCH] drm/amd/display: Fix out-of-bounds stream encoder index Srinivasan Shanmugam
2026-02-09 23:34 ` Li, Roman
2026-02-10  6:59   ` Dan Carpenter [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=aYrXTyT6G2u--dFJ@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=Alex.Hung@amd.com \
    --cc=Aurabindo.Pillai@amd.com \
    --cc=ChiaHsuan.Chung@amd.com \
    --cc=Harry.Wentland@amd.com \
    --cc=Roman.Li@amd.com \
    --cc=SRINIVASAN.SHANMUGAM@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=superm1@kernel.org \
    /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.