Re: [PATCH v3 2/2] net: pcs: rzn1-miic: Verify port number from dtb

From: Lad, Prabhakar

Date: Mon Sep 07 2026 - 17:23:58 EST


Hi Andrew,

On Mon, Sep 7, 2026 at 9:49 PM Andrew Lunn <andrew@xxxxxxx> wrote:
>
> On Mon, Sep 07, 2026 at 08:39:27PM +0100, Lad, Prabhakar wrote:
> > Hi Kyle,
> >
> > Thank you for the patch.
> >
> > On Wed, Sep 2, 2026 at 7:55 PM Kyle Hendry via B4 Relay
> > <devnull+khendry.reliablecontrols.com@xxxxxxxxxx> wrote:
> > >
> > > From: Kyle Hendry <khendry@xxxxxxxxxxxxxxxxxxxx>
> > >
> > > Add check to make sure port number is in range before writing
> > > to dt_val array
> > >
> > > Signed-off-by: Kyle Hendry <khendry@xxxxxxxxxxxxxxxxxxxx>
> > > ---
> > > drivers/net/pcs/pcs-rzn1-miic.c | 6 ++++++
> > > 1 file changed, 6 insertions(+)
> > >
> > > diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
> > > index c50b65d064fa..3ee40eb9d545 100644
> > > --- a/drivers/net/pcs/pcs-rzn1-miic.c
> > > +++ b/drivers/net/pcs/pcs-rzn1-miic.c
> > > @@ -692,6 +692,12 @@ static int miic_parse_dt(struct miic *miic, u32 *mode_cfg)
> > > if (of_property_read_u32(conv, "reg", &port))
> > > continue;
> > >
> > > + if (port < miic->of_data->miic_port_start || port > miic->of_data->miic_port_max) {
> > > + dev_err(miic->dev, "Port number out of range: %d\n", port);
> > > + kfree(dt_val);
> > > + return -EINVAL;
> > > + }
> > > +
> > Query to maintainers, what policy should be followed? Since the
> > dtbinding check complains if the port is out of range should the code
> > also check it?
>
> Yes, the kernel should check it. Running the checker is
> optional. Crashing the kernel because of an invalid DT blob is not
> something you want to allow.
>
Ack, I'll make a note of it.

Cheers,
Prabhakar