Re: [PATCH 01/10] staging: gasket: save struct device for a gasket device

From: Greg Kroah-Hartman
Date: Fri Jul 27 2018 - 11:09:02 EST


On Thu, Jul 26, 2018 at 08:07:28PM -0700, Todd Poynor wrote:
> From: Todd Poynor <toddpoynor@xxxxxxxxxx>
>
> Save the struct device pointer to a gasket device in gasket's metadata,
> to facilitate use of standard logging calls and in anticipation of
> non-PCI gasket devices in the future.
>
> Signed-off-by: Todd Poynor <toddpoynor@xxxxxxxxxx>
> ---
> drivers/staging/gasket/gasket_core.c | 5 +++--
> drivers/staging/gasket/gasket_core.h | 3 +++
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
> index 732218773c3c6..e8f3b021c20d1 100644
> --- a/drivers/staging/gasket/gasket_core.c
> +++ b/drivers/staging/gasket/gasket_core.c
> @@ -450,6 +450,7 @@ static int gasket_alloc_dev(
> gasket_dev->internal_desc = internal_desc;
> gasket_dev->dev_idx = dev_idx;
> snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", kobj_name);
> + gasket_dev->dev = parent;

Normally when saving off a pointer to an object that you reference later
on, and that you rely on, you need to grab a reference to it, otherwise
it may disappear at any point in time.

However this whole "wrap the pci layer" nonsense is a total mess with
the lifetime rules of devices, so it's probably the least of your
worries....

As long as you know you will have to fix that crud up, and what you are
doing here will bite you if you do not do it right, that's fine with
me...

thanks,

greg k-h