Răsfoiți Sursa

staging: gasket: core: hold reference on device while in use

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>
Todd Poynor 7 ani în urmă
părinte
comite
5b6e80cc98
1 a modificat fișierele cu 2 adăugiri și 2 ștergeri
  1. 2 2
      drivers/staging/gasket/gasket_core.c

+ 2 - 2
drivers/staging/gasket/gasket_core.c

@@ -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);
 }