[igt-dev] [PATCH] lib/igt_chamelium: Extend check of valid ports to port=0

Mark Yacoub markyacoub at chromium.org
Fri Jul 29 14:53:52 UTC 2022


On Fri, Jul 29, 2022 at 9:14 AM Petri Latvala <petri.latvala at intel.com> wrote:
>
> On Fri, Jul 15, 2022 at 03:22:00PM -0400, Mark Yacoub wrote:
> > [Why]
> > Chamelium V3 has a valid port at 0 so 0 should not be rejected.
> >
> > [How]
> > Check for port values between 0 and CHAMELIUM_MAX_PORTS which should
> > also include the V2 ports range.
> >
> > Test: ./kms_chamelium --run-subtest dp-hp
> > Tested on: Volteer & cv3
> >
> > Signed-off-by: Mark Yacoub <markyacoub at chromium.org>
> > ---
> >  lib/igt_chamelium.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> > index 55cbfa12..5d68372b 100644
> > --- a/lib/igt_chamelium.c
> > +++ b/lib/igt_chamelium.c
> > @@ -2311,7 +2311,7 @@ static bool chamelium_read_port_mappings(struct chamelium *chamelium,
> >               port->id = g_key_file_get_integer(igt_key_file, group,
> >                                                 "ChameliumPortID",
> >                                                 &error);
> > -             if (!port->id) {
> > +             if (port->id < 0 || port->id > CHAMELIUM_MAX_PORTS) {
>
> You rather need to check whether 'error' is set to something. 0 might
> be a valid port id in v3 but it's also what g_key_file_get_integer
> returns on error.
Updated om v2: https://patchwork.freedesktop.org/patch/495936/
Thanks! that was easy.
>
>
> --
> Petri Latvala
>
>
> >                       igt_warn("Failed to read chamelium port ID for %s: %s\n",
> >                                map_name, error->message);
> >                       ret = false;
> > --
> > 2.37.0.170.g444d1eabd0-goog
> >


More information about the igt-dev mailing list