[PATCH i-g-t 2/2] tests/intel: check drmModeGetConnector() return value in i915_pm_rpm

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


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

one more nit about subject, please keep it short,
instead of:

[PATCH i-g-t 2/2] tests/intel: check drmModeGetConnector() return value in i915_pm_rpm

imho better:

[PATCH i-g-t 2/2] tests/intel/i915_pm_rpm: avoid NULL dereference

Regards,
Kamil

> 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 init_mode_set_data(), so fix that.
> 
> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/10911
> Signed-off-by: Luca Coelho <luciano.coelho at intel.com>
> ---
>  tests/intel/i915_pm_rpm.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tests/intel/i915_pm_rpm.c b/tests/intel/i915_pm_rpm.c
> index 52e00489da70..10a545f173de 100644
> --- a/tests/intel/i915_pm_rpm.c
> +++ b/tests/intel/i915_pm_rpm.c
> @@ -515,6 +515,12 @@ static void init_mode_set_data(struct mode_set_data *data)
>  			data->connectors[i] =
>  				drmModeGetConnector(drm_fd,
>  						    data->res->connectors[i]);
> +			if (!data->connectors[i]) {
> +				igt_warn("Could not read connector %u\n",
> +					 data->res->connectors[i]);
> +				continue;
> +			}
> +
>  			data->edids[i] = get_connector_edid(data->connectors[i], i);
>  		}
>  
> -- 
> 2.39.2
> 


More information about the igt-dev mailing list