[igt-dev] [PATCH i-g-t v2 7/9] lib/igt_chamelium: set EDID serial

Arkadiusz Hiler arkadiusz.hiler at intel.com
Mon Jun 24 12:16:28 UTC 2019


On Wed, Jun 19, 2019 at 06:55:16PM +0300, Simon Ser wrote:
> Set a different EDID serial string for each Chamelium port, so that we can
> easily tell which DRM connector maps to a Chamelium port.
> 
> Signed-off-by: Simon Ser <simon.ser at intel.com>
> ---
>  lib/igt_chamelium.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> index 467f1a458516..dcc59e9f0b04 100644
> --- a/lib/igt_chamelium.c
> +++ b/lib/igt_chamelium.c
> @@ -587,6 +587,17 @@ struct chamelium_edid *chamelium_new_edid(struct chamelium *chamelium,
>  const struct edid *chamelium_edid_get_raw(struct chamelium_edid *edid,
>  					  struct chamelium_port *port)
>  {
> +	uint32_t *serial;
> +
> +	/* Product code: Chamelium */
> +	edid->raw->prod_code[0] = 'C';
> +	edid->raw->prod_code[1] = 'H';
> +
> +	/* Serial: Chamelium port ID */
> +	serial = (uint32_t *) &edid->raw->serial;
> +	*serial = port->id;
> +
> +	edid_update_checksum(edid->raw);
>  	return edid->raw;
>  }

Reusing the same memory and modifying it with each call is a pitfall for
consumers of this API. Either store a copy for each connector, memcpy to
a user provided pointer or return a copy and make the caller responsible
for free()-ing it.

I vaugely remember fixing issues caused by abuse of similar functions
that modifed a static memory and returning a pointer to it.

-- 
Cheers,
Arek


More information about the igt-dev mailing list