From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Todd Poynor <toddpoynor@gmail.com>
Cc: Rob Springer <rspringer@google.com>,
John Joseph <jnjoseph@google.com>,
Ben Chan <benchan@chromium.org>,
devel@driverdev.osuosl.org, Todd Poynor <toddpoynor@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/staging/gasket: Use refcount_read()
Date: Sat, 7 Jul 2018 09:22:24 +0200 [thread overview]
Message-ID: <20180707072224.GA9377@kroah.com> (raw)
In-Reply-To: <20180707064310.199121-1-toddpoynor@gmail.com>
On Fri, Jul 06, 2018 at 11:43:10PM -0700, Todd Poynor wrote:
> From: Todd Poynor <toddpoynor@google.com>
>
> Use the refcount_read accessor function, avoid reaching into refcount
> and atomic struct fields.
>
> Signed-off-by: Todd Poynor <toddpoynor@google.com>
> ---
> drivers/staging/gasket/gasket_sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c
> index d45098c90b4b..b5cdc180772a 100644
> --- a/drivers/staging/gasket/gasket_sysfs.c
> +++ b/drivers/staging/gasket/gasket_sysfs.c
> @@ -122,7 +122,7 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping)
> }
>
> mutex_lock(&mapping->mutex);
> - if (mapping->refcount.refcount.refs.counter == 0)
> + if (refcount_read(&mapping->refcount.refcount) == 0)
> gasket_nodev_error("Refcount is already 0!");
> if (kref_put(&mapping->refcount, release_entry)) {
> gasket_nodev_info("Removing Gasket sysfs mapping, device %s",
Thanks for the patch, but ugh, why in the world is this driver even
doing this type of thing? Odds are all of these reference counting
checks can be removed, something else to add to the "todo" file...
thanks,
greg k-h
prev parent reply other threads:[~2018-07-07 7:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-07 6:43 [PATCH] drivers/staging/gasket: Use refcount_read() Todd Poynor
2018-07-07 7:22 ` Greg Kroah-Hartman [this message]
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=20180707072224.GA9377@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=benchan@chromium.org \
--cc=devel@driverdev.osuosl.org \
--cc=jnjoseph@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rspringer@google.com \
--cc=toddpoynor@gmail.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