Commit b41ca62c authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Michael S. Tsirkin
Browse files

virtio: vdpa: Fix reference count leak in octep_sriov_enable()



pci_get_device() will increase the reference count for the returned
pci_dev, and also decrease the reference count for the input parameter
from if it is not NULL.

If we break the loop in  with 'vf_pdev' not NULL. We
need to call pci_dev_put() to decrease the reference count.

Found via static anlaysis and this is similar to commit c508eb04
("perf/x86/intel/uncore: Fix reference count leak in sad_cfg_iio_topology()")

Fixes: 8b6c724c ("virtio: vdpa: vDPA driver for Marvell OCTEON DPU devices")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Message-Id: <20251027060737.33815-1-linmq006@gmail.com>
parent f0ea2e91
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -736,6 +736,7 @@ static int octep_sriov_enable(struct pci_dev *pdev, int num_vfs)
		octep_vdpa_assign_barspace(vf_pdev, pdev, index);
		if (++index == num_vfs) {
			done = true;
			pci_dev_put(vf_pdev);
			break;
		}
	}