[PATCH i-g-t 1/2] lib/igt_chamelium: check drmModeGetConnector() return value in wait_for_connected_state()

Kamil Konieczny kamil.konieczny at linux.intel.com
Fri May 24 16:58:35 UTC 2024


Hi Luca,
On 2024-05-23 at 11:44:25 +0300, Luca Coelho wrote:

I have two nits, one about too long subject:

[PATCH i-g-t 1/2] lib/igt_chamelium: check drmModeGetConnector() return value in wait_for_connected_state()

imho better:

[PATCH i-g-t 1/2] lib/igt_chamelium: avoid NULL dereference in wait_for_connected_state()

or even shorter:

[PATCH i-g-t 1/2] lib/igt_chamelium: fix wait_for_connected_state()

Maybe that should be changed to something else? See my other
response.

> The drmModeGetConnector() function can return NULL in some cases, so
> we need to check the return value before accessing it.  This is not
> being checked in wait_for_connected_state(), so fix that.
> 

Also please add to Cc chromium devs, for example:

Cc: Mark Yacoub <markyacoub at chromium.org>
Cc: Manasi Navare <navaremanasi at chromium.org>
> Signed-off-by: Luca Coelho <luciano.coelho at intel.com>

Regards,
Kamil

> ---
>  lib/igt_chamelium.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> index 016d5356630c..b1478654d02a 100644
> --- a/lib/igt_chamelium.c
> +++ b/lib/igt_chamelium.c
> @@ -524,6 +524,9 @@ static bool wait_for_connected_state(int drm_fd,
>  			drmModeConnector *connector =
>  				drmModeGetConnector(drm_fd, connectors[i]);
>  
> +			if (!connector)
> +				break;
> +
>  			connected = connector->connection == DRM_MODE_CONNECTED;
>  
>  			drmModeFreeConnector(connector);
> -- 
> 2.39.2
> 


More information about the igt-dev mailing list