lkml.org 
[lkml]   [2020]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 07/18] nitro_enclaves: Init misc device providing the ioctl interface
On Mon, Jun 22, 2020 at 11:03:18PM +0300, Andra Paraschiv wrote:
> +static int __init ne_init(void)
> +{
> + struct pci_dev *pdev = pci_get_device(PCI_VENDOR_ID_AMAZON,
> + PCI_DEVICE_ID_NE, NULL);
> + int rc = -EINVAL;
> +
> + if (!pdev)
> + return -ENODEV;

Ick, that's a _very_ old-school way of binding to a pci device. Please
just be a "real" pci driver and your probe function will be called if
your hardware is present (or when it shows up.) To do it this way
prevents your driver from being auto-loaded for when your hardware is
seen in the system, as well as lots of other things.

> +
> + if (!zalloc_cpumask_var(&ne_cpu_pool.avail, GFP_KERNEL))
> + return -ENOMEM;
> +
> + mutex_init(&ne_cpu_pool.mutex);
> +
> + rc = pci_register_driver(&ne_pci_driver);

Nice, you did it right here, but why the above crazy test?

> + if (rc < 0) {
> + dev_err(&pdev->dev,
> + "Error in pci register driver [rc=%d]\n", rc);
> +
> + goto free_cpumask;
> + }
> +
> + return 0;

You leaked a reference on that pci device, didn't you? Not good :(

thanks,

greg k-h

\
 
 \ /
  Last update: 2020-06-29 23:25    [W:0.250 / U:5.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site