Linux bluetooth development
 help / color / mirror / Atom feed
From: Karl Relton <karllinuxtest.relton@ntlworld.com>
To: linux-bluetooth@vger.kernel.org
Cc: dh.herrmann@gmail.com, Marcel Holtmann <marcel@holtmann.org>,
	Gustavo Padovan <gustavo@padovan.org>,
	Johan Hedberg <johan.hedberg@gmail.com>
Subject: Re: [PATCH v2] hidp: Make hidp_get_raw_report abort if the session is terminating.
Date: Thu, 21 Feb 2013 08:42:12 +0000	[thread overview]
Message-ID: <1361436132.2792.4.camel@dellpc> (raw)
In-Reply-To: <1361384179.5261.15.camel@dellpc>

On Wed, 2013-02-20 at 18:16 +0000, Karl Relton wrote:
> From: Karl Relton <karllinuxtest.relton@ntlworld.com>
> 
>  After linux 3.2 the hid_destroy_device call in hidp_session
>  cleaning up invokes a hook to the power_supply code which
>  in turn tries to read the battery capacity. This read will
>  trigger a call to hidp_get_raw_report which is bound to fail
>  because the device is being taken away - so rather than
>  wait for the 5 second timeout failure this changes enables
>  it to fail straight away.
> 
> Signed-off-by: Karl Relton <karllinuxtest.relton@ntlworld.com>
> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  net/bluetooth/hidp/core.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
> index b2bcbe2..4b26ea7 100644
> --- a/net/bluetooth/hidp/core.c
> +++ b/net/bluetooth/hidp/core.c
> @@ -311,6 +311,9 @@ static int hidp_get_raw_report(struct hid_device *hid,
>  	int numbered_reports = hid->report_enum[report_type].numbered;
>  	int ret;
>  
> +	if (atomic_read(&session->terminate))
> +		return -EIO;
> +
>  	switch (report_type) {

Actually I've just realised that hidp_get_raw_report calls
__hidp_send_ctrl_message which already has the session->terminate test,
also returning -EIO on failure. So adding it again here is redundant.

> @@ -722,6 +725,7 @@ static int hidp_session(void *arg)
>  		set_current_state(TASK_INTERRUPTIBLE);
>  	}
>  	set_current_state(TASK_RUNNING);
> +	atomic_inc(&session->terminate);
>  	remove_wait_queue(sk_sleep(intr_sk), &intr_wait);
>  	remove_wait_queue(sk_sleep(ctrl_sk), &ctrl_wait);
>  

So its just this one single line we need - to ensure session->terminate
is non-zero, which will ensure calls to other things (like
hidp_get_raw_report) abort swiftly.

I'll change the patch and send v3 this evening (need to get back to the
day job!).

Karl

  reply	other threads:[~2013-02-21  8:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-20 18:16 [PATCH v2] hidp: Make hidp_get_raw_report abort if the session is terminating Karl Relton
2013-02-21  8:42 ` Karl Relton [this message]
2013-02-26 19:30 ` Gustavo Padovan

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=1361436132.2792.4.camel@dellpc \
    --to=karllinuxtest.relton@ntlworld.com \
    --cc=dh.herrmann@gmail.com \
    --cc=gustavo@padovan.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /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