Message ID | 20230515051500.574127-2-dlemoal@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Fixup changes to pci_epf_type_add_cfs() | expand |
On Mon, May 15, 2023 at 02:14:59PM +0900, Damien Le Moal wrote: > 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(-EINVAL) > error return. > Shouldn't the error code be -ENODEV? - Mani > Signed-off-by: Damien Le Moal <dlemoal@kernel.org> > --- > drivers/pci/endpoint/pci-ep-cfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c > index 0fb6c376166f..d8a6abe2c31c 100644 > --- a/drivers/pci/endpoint/pci-ep-cfs.c > +++ b/drivers/pci/endpoint/pci-ep-cfs.c > @@ -516,7 +516,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(-EINVAL); > } > > if (!epf->driver->ops->add_cfs) > -- > 2.40.1 >
On 5/15/23 16:19, Manivannan Sadhasivami wrote: > On Mon, May 15, 2023 at 02:14:59PM +0900, Damien Le Moal wrote: >> 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(-EINVAL) >> error return. >> > > Shouldn't the error code be -ENODEV? Yeah, I wondered about it and settled for EINVAL... Will change to ENODEV. > > - Mani > >> Signed-off-by: Damien Le Moal <dlemoal@kernel.org> >> --- >> drivers/pci/endpoint/pci-ep-cfs.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c >> index 0fb6c376166f..d8a6abe2c31c 100644 >> --- a/drivers/pci/endpoint/pci-ep-cfs.c >> +++ b/drivers/pci/endpoint/pci-ep-cfs.c >> @@ -516,7 +516,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(-EINVAL); >> } >> >> if (!epf->driver->ops->add_cfs) >> -- >> 2.40.1 >> >
diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c index 0fb6c376166f..d8a6abe2c31c 100644 --- a/drivers/pci/endpoint/pci-ep-cfs.c +++ b/drivers/pci/endpoint/pci-ep-cfs.c @@ -516,7 +516,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(-EINVAL); } if (!epf->driver->ops->add_cfs)
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(-EINVAL) error return. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> --- drivers/pci/endpoint/pci-ep-cfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)