Re: [PATCH v8 2/2] can: esd: add support for esd GmbH PCIe/402 CAN interface family

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Freitag, dem 03.11.2023 um 16:48 +0000 schrieb Simon Horman:
> On Wed, Oct 25, 2023 at 04:16:35PM +0200, Stefan Mätje wrote:
> > This patch adds support for the PCI based PCIe/402 CAN interface family
> > from esd GmbH that is available with various form factors
> > (https://esd.eu/en/products/402-series-can-interfaces).
> > 
> > All boards utilize a FPGA based CAN controller solution developed
> > by esd (esdACC). For more information on the esdACC see
> > https://esd.eu/en/products/esdacc.
> > 
> > This driver detects all available CAN interface board variants of
> > the family but atm. operates the CAN-FD capable devices in
> > Classic-CAN mode only! A later patch will introduce the CAN-FD
> > functionality in this driver.
> > 
> > Co-developed-by: Thomas Körper <thomas.koerper@xxxxxx>
> > Signed-off-by: Thomas Körper <thomas.koerper@xxxxxx>
> > Signed-off-by: Stefan Mätje <stefan.maetje@xxxxxx>
> 
> ...
> 
> > +static int pci402_probe(struct pci_dev *pdev, const struct pci_device_id
> > *ent)
> > +{
> > +       struct pci402_card *card = NULL;
> > +       int err;
> > +
> > +       err = pci_enable_device(pdev);
> > +       if (err)
> > +               return err;
> > +
> > +       card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL);
> > +       if (!card)
> 
> Hi Thomas and Stefan,
> 
> If this condition is met then the function will return err,
> but err is set to 0. Perhaps it should be set to an error value here?
> 
> Flagged by Smatch.

Hi Simon,

thank you for reviewing this. Looking at the code it is apparently wrong.

I was not aware of smatch. I got a copy and could reproduce the error report.
This will add another tool of static code analysis to my release routine.

An upgraded patch with a fix will follow.

Best regards,
    Stefan

> > +               goto failure_disable_pci;
> > +
> > +       pci_set_drvdata(pdev, card);
> > +
> > +       err = pci_request_regions(pdev, pci_name(pdev));
> > +       if (err)
> > +               goto failure_disable_pci;
> > +
> > +       card->addr = pci_iomap(pdev, PCI402_BAR, PCI402_IO_LEN_TOTAL);
> > +       if (!card->addr) {
> > +               err = -ENOMEM;
> > +               goto failure_release_regions;
> > +       }
> > +
> > +       err = pci402_init_card(pdev);
> > +       if (err)
> > +               goto failure_unmap;
> > +
> > +       err = pci402_init_dma(pdev);
> > +       if (err)
> > +               goto failure_unmap;
> > +
> > +       err = pci402_init_interrupt(pdev);
> > +       if (err)
> > +               goto failure_finish_dma;
> > +
> > +       err = pci402_init_cores(pdev);
> > +       if (err)
> > +               goto failure_finish_interrupt;
> > +
> > +       return 0;
> > +
> > +failure_finish_interrupt:
> > +       pci402_finish_interrupt(pdev);
> > +
> > +failure_finish_dma:
> > +       pci402_finish_dma(pdev);
> > +
> > +failure_unmap:
> > +       pci_iounmap(pdev, card->addr);
> > +
> > +failure_release_regions:
> > +       pci_release_regions(pdev);
> > +
> > +failure_disable_pci:
> > +       pci_disable_device(pdev);
> > +
> > +       return err;
> > +}
> 
> ...





[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux