patch 'bus/pci/bsd: fix device existence check' has been queued to stable release 22.11.9

Jake Freeland jfree at freebsd.org
Tue Jun 17 20:38:03 CEST 2025


On Thu Jun 12, 2025 at 4:07 PM CDT, luca.boccassi wrote:
> Hi,
>
> FYI, your patch has been queued to stable release 22.11.9
>
> Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
> It will be pushed if I get no objections before 06/14/25. So please
> shout if anyone has objections.
>
> Also note that after the patch there's a diff of the upstream commit vs the
> patch applied to the branch. This will indicate if there was any rebasing
> needed to apply to the stable branch. If there were code changes for rebasing
> (ie: not only metadata diffs), please double check that the rebase was
> correctly done.

I'm a little late, but the rebase diff looks good to me.

Thanks,
Jake Freeland

> Queued patches are on a temporary branch at:
> https://github.com/bluca/dpdk-stable
>
> This queued commit can be viewed at:
> https://github.com/bluca/dpdk-stable/commit/605117a0ccd604b73b4de19fadd24e228329a930
>
> Thanks.
>
> Luca Boccassi
>
> ---
> From 605117a0ccd604b73b4de19fadd24e228329a930 Mon Sep 17 00:00:00 2001
> From: Jake Freeland <jfree at freebsd.org>
> Date: Tue, 6 May 2025 12:40:44 -0500
> Subject: [PATCH] bus/pci/bsd: fix device existence check
>
> [ upstream commit 6d4e6dbccc3bd965bfd5e5836d7cb21c1b1f9c6c ]
>
> Use open(2) instead of access(2) to check for the existence of the target
> device. This avoids a possible race condition where the device file is
> removed after a successful call to access(2) but before open(2).
>
> This also fixes any potential bugs associated with passing open(2)-style
> flags into access(2). i.e. access(2) does not formally support the O_RDWR
> flag.
>
> Fixes: 764bf26873b9 ("add FreeBSD support")
>
> Signed-off-by: Jake Freeland <jfree at freebsd.org>
> Acked-by: Anatoly Burakov <anatoly.burakov at intel.com>
> ---
>  drivers/bus/pci/bsd/pci.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c
> index 7459d15c7e..b11cfdd450 100644
> --- a/drivers/bus/pci/bsd/pci.c
> +++ b/drivers/bus/pci/bsd/pci.c
> @@ -105,20 +105,27 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
>  {
>  	char devname[PATH_MAX]; /* contains the /dev/uioX */
>  	struct rte_pci_addr *loc;
> +	int fd;
>  
>  	loc = &dev->addr;
>  
>  	snprintf(devname, sizeof(devname), "/dev/uio at pci:%u:%u:%u",
>  			dev->addr.bus, dev->addr.devid, dev->addr.function);
>  
> -	if (access(devname, O_RDWR) < 0) {
> -		RTE_LOG(WARNING, EAL, "  "PCI_PRI_FMT" not managed by UIO driver, "
> -				"skipping\n", loc->domain, loc->bus, loc->devid, loc->function);
> -		return 1;
> +	fd = open(devname, O_RDWR);
> +	if (fd < 0) {
> +		if (errno == ENOENT) {
> +			RTE_LOG(WARNING, EAL, PCI_PRI_FMT" not managed by UIO driver, skipping\n",
> +					loc->domain, loc->bus, loc->devid, loc->function);
> +			return 1;
> +		}
> +		RTE_LOG(ERR, EAL, "Failed to open device file for " PCI_PRI_FMT " (%s)\n",
> +				loc->domain, loc->bus, loc->devid, loc->function, devname);
> +		return -1;
>  	}
>  
>  	/* save fd if in primary process */
> -	if (rte_intr_fd_set(dev->intr_handle, open(devname, O_RDWR))) {
> +	if (rte_intr_fd_set(dev->intr_handle, fd)) {
>  		RTE_LOG(WARNING, EAL, "Failed to save fd");
>  		goto error;
>  	}



More information about the stable mailing list