OSDN Git Service

staging: gasket: core: hold reference on device while in use
authorTodd Poynor <toddpoynor@google.com>
Sat, 28 Jul 2018 19:33:24 +0000 (12:33 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 29 Jul 2018 06:05:45 +0000 (08:05 +0200)
Hold a reference on the struct device while a pointer to that
device is in use by gasket.

Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gasket/gasket_core.c

index 859a6df..2b484d0 100644 (file)
@@ -448,7 +448,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;
+       gasket_dev->dev = get_device(parent);
        /* gasket_bar_data is uninitialized. */
        gasket_dev->num_page_tables = driver_desc->num_page_tables;
        /* max_page_table_size and *page table are uninit'ed */
@@ -487,7 +487,7 @@ static void gasket_free_dev(struct gasket_dev *gasket_dev)
        mutex_lock(&internal_desc->mutex);
        internal_desc->devs[gasket_dev->dev_idx] = NULL;
        mutex_unlock(&internal_desc->mutex);
-
+       put_device(gasket_dev->dev);
        kfree(gasket_dev);
 }