Re: [PATCH 01/13] staging: gasket: core: hold reference to pci_dev while used

From: Dmitry Torokhov
Date: Tue Jul 31 2018 - 02:19:08 EST


On Sun, Jul 29, 2018 at 12:37 PM Todd Poynor <toddpoynor@xxxxxxxxx> wrote:
>
> From: Todd Poynor <toddpoynor@xxxxxxxxxx>
>
> Hold a reference on the struct pci_dev while a pointer to it is held in
> the gasket data structures.
>
> Signed-off-by: Todd Poynor <toddpoynor@xxxxxxxxxx>
> ---
> drivers/staging/gasket/gasket_core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
> index 2b484d067c38a..b832a4f529f27 100644
> --- a/drivers/staging/gasket/gasket_core.c
> +++ b/drivers/staging/gasket/gasket_core.c
> @@ -488,6 +488,7 @@ static void gasket_free_dev(struct gasket_dev *gasket_dev)
> internal_desc->devs[gasket_dev->dev_idx] = NULL;
> mutex_unlock(&internal_desc->mutex);
> put_device(gasket_dev->dev);
> + pci_dev_put(gasket_dev->pci_dev);

gasket_free_dev() is called only from driver PCI probe and remove
function. I can assure you that that pci_dev structure is not going
anywhere, there is no need to take this additional reference.

Thanks,
Dmitry