Re: [PATCH 5/5] staging: gasket: core: hold reference on device kobj while in use

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

 



On Fri, Jul 27, 2018 at 10:22:00PM -0700, Todd Poynor wrote:
> From: Todd Poynor <toddpoynor@xxxxxxxxxx>
> 
> Hold a reference on the struct device kobject while a pointer to that
> device is in use by gasket.
> 
> Reported-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Todd Poynor <toddpoynor@xxxxxxxxxx>
> ---
>  drivers/staging/gasket/gasket_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
> index 859a6df9e12df..1dc7273e38734 100644
> --- a/drivers/staging/gasket/gasket_core.c
> +++ b/drivers/staging/gasket/gasket_core.c
> @@ -449,6 +449,7 @@ static int gasket_alloc_dev(
>  	gasket_dev->dev_idx = dev_idx;
>  	snprintf(gasket_dev->kobj_name, GASKET_NAME_MAX, "%s", kobj_name);
>  	gasket_dev->dev = parent;
> +	kobject_get(&gasket_dev->dev->kobj);

Hint, if you are a driver, working with devices, you should never call a
kobject_* or sysfs_* call.  If you are, you are doing something really
wrong and odd and should seriously reconsider it.  No driver should ever
be touching a "raw" kobject.

For this case, get_device()/put_device() is what you should be using.

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux