mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Todd Poynor <toddpoynor@gmail.com>
To: Rob Springer <rspringer@google.com>,
	John Joseph <jnjoseph@google.com>,
	Ben Chan <benchan@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Todd Poynor <toddpoynor@google.com>
Subject: [PATCH 5/5] staging: gasket: core: hold reference on device kobj while in use
Date: Fri, 27 Jul 2018 22:22:00 -0700	[thread overview]
Message-ID: <20180728052200.228796-6-toddpoynor@gmail.com> (raw)
In-Reply-To: <20180728052200.228796-1-toddpoynor@gmail.com>

From: Todd Poynor <toddpoynor@google.com>

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@linuxfoundation.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
---
 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);
 	/* 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 +488,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);
-
+	kobject_put(&gasket_dev->dev->kobj);
 	kfree(gasket_dev);
 }
 
-- 
2.18.0.345.g5c9ce644c3-goog


  parent reply	other threads:[~2018-07-28  5:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-28  5:21 [PATCH 0/5] staging: gasket: fixes and cleanups Todd Poynor
2018-07-28  5:21 ` [PATCH 1/5] staging: gasket: sysfs: remove check for refcount already zero Todd Poynor
2018-07-28  5:21 ` [PATCH 2/5] staging: gasket: apex: fixup undefined PCI class Todd Poynor
2018-07-28  5:21 ` [PATCH 3/5] staging: gasket: sysfs: remove unnecessary NULL check on device ptr Todd Poynor
2018-07-28  5:21 ` [PATCH 4/5] staging: gasket: page table: remove code for "no dma_ops" Todd Poynor
2018-07-28  5:22 ` Todd Poynor [this message]
2018-07-28  7:23   ` [PATCH 5/5] staging: gasket: core: hold reference on device kobj while in use Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180728052200.228796-6-toddpoynor@gmail.com \
    --to=toddpoynor@gmail.com \
    --cc=benchan@chromium.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jnjoseph@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rspringer@google.com \
    --cc=toddpoynor@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®