PCI: endpoint: Improve pci_epf_type_add_cfs()
authorDamien Le Moal <dlemoal@kernel.org>
Mon, 15 May 2023 07:43:47 +0000 (16:43 +0900)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 23 Jun 2023 20:04:36 +0000 (15:04 -0500)
pci_epf_type_add_cfs() should not be called with an unbound EPF device,
that is, an epf device with epf->driver not set. For such case, replace the
NULL return in pci_epf_type_add_cfs() with a clear ERR_PTR(-ENODEV) pointer
error return.

Link: https://lore.kernel.org/r/20230515074348.595704-2-dlemoal@kernel.org
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Manivannan Sadhasivami <manivannan.sadhasivam@linaro.org>
drivers/pci/endpoint/pci-ep-cfs.c

index cd99ac8..18e061a 100644 (file)
@@ -532,7 +532,7 @@ static struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf,
 
        if (!epf->driver) {
                dev_err(&epf->dev, "epf device not bound to driver\n");
-               return NULL;
+               return ERR_PTR(-ENODEV);
        }
 
        if (!epf->driver->ops->add_cfs)