[PATCH i-g-t 3/3] lib/igt_facts: Fix potential NULL pointer dereference

Kamil Konieczny kamil.konieczny at linux.intel.com
Fri Apr 25 13:20:55 UTC 2025


Hi Peter,
On 2025-04-25 at 11:49:04 +0200, Peter Senna Tschudin wrote:
> If both udev_device_get_sysattr_value and udev_device_get_sysname fail,
> pci_addr will remain NULL, which could lead to issues when using it
> later in asprintf. Ignore cards when pci_addr cannot be extracted.
> 
> Signed-off-by: Peter Senna Tschudin <peter.senna at linux.intel.com>

LGTM
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

> ---
>  lib/igt_facts.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/igt_facts.c b/lib/igt_facts.c
> index d38be0726..47a2c98a5 100644
> --- a/lib/igt_facts.c
> +++ b/lib/igt_facts.c
> @@ -537,6 +537,10 @@ static void igt_facts_scan_pci_drm_cards(const char *last_test)
>  								 "address");
>  			if (!pci_addr)
>  				pci_addr = udev_device_get_sysname(pci_dev);
> +			if (!pci_addr) {
> +				udev_device_unref(drm_dev);
> +				continue;
> +			}
>  		} else {
>  			/* Some GPUs are platform devices. Ignore them. */
>  			pci_addr = NULL;
> -- 
> 2.43.0
> 


More information about the igt-dev mailing list