linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: navin patidar <navinp@cdac.in>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: gregkh@linuxfoundation.org, mfm@muteddisk.com,
	devel@driverdev.osuosl.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: usbip: stub_dev: Fixed oops during removal of usbip_host
Date: Tue, 18 Sep 2012 17:14:41 +0530	[thread overview]
Message-ID: <CAPV97yfRd_1Ak+DniNyg+vhg1bkOPqzGwRu-LSKXkpW2=_xw+Q@mail.gmail.com> (raw)
In-Reply-To: <20120918093619.GO13767@mwanda>

for usbip_host  event_handler()   handles following events.  defined
in "usbip_common.h"

 1. SDEV_EVENT_REMOVED   (USBIP_EH_SHUTDOWN | USBIP_EH_RESET | USBIP_EH_BYE)
 2. SDEV_EVENT_DOWN		(USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
 3. SDEV_EVENT_ERROR_TCP	(USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
 4. SDEV_EVENT_ERROR_SUBMIT	(USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
 5. VDEV_EVENT_ERROR_MALLOC (USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE)

In case of events(1,2,3,4),  stub_shoutdown_connection() gets executed
first and than stub_device_reset() .

In case of event 5, stub_shoutdown_connection()  kills kernel threads
and stub_device_unusable()   changes devices status to
"SDEV_ST_ERROR"(fatal error).

 thus stub_device_reset() can't  be called without
stub_shutdown_connection(), so there is no problem of resource leak .
you are also right, i could have set pointers to  NULL in
stub_shutdown_connection() but i used  stub_device_reset() which is
intended to reset usbip_device stuct member variables.

i'll resend patches, if maintainer ask for that.
thanks

--navin-patidar


On Tue, Sep 18, 2012 at 3:06 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Tue, Sep 18, 2012 at 03:02:15PM +0530, navin patidar wrote:
>> On Tue, Sep 18, 2012 at 1:10 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>> > On Tue, Sep 18, 2012 at 09:30:06AM +0530, navin patidar wrote:
>> >> stub_device_reset should set kernel thread pointers to NULL.
>> >> so that at the time of usbip_host removal stub_shoutdown_connection
>> >> doesn't try to kill kernel threads which are already killed.
>> >>
>> >
>> > If you have the Oops output, that's always nice to put in the commit
>> > message.
>>
>> i'll surely keep this in mind  before submitting further patches.
>>
>> > Why don't you set the pointers to NULL in stub_shutdown_connection()
>> > since that's where you actually kill the threads.  Setting them to
>> > NULL in stub_device_reset() will (sometimes) solve the problem but
>> > it gives you a new problem of a resource leak.
>>
>>  stub_device_reset() always gets executed after
>> stub_shutdown_connection() , never before.
>>
>
> No it isn't.  Read event_handler() more carefully.  They can be
> executed independently.
>
> In other words, stub_shutdown_connection() can be called without
> calling stub_device_reset() and stub_device_reset() can be called
> without stub_shutdown_connection().  If either of those happen then
> it causes a problem with the patch you have just sent.
>
> regards,
> dan carpenter
>

  reply	other threads:[~2012-09-18 11:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-18  4:00 [PATCH] staging: usbip: stub_dev: Fixed oops during removal of usbip_host navin patidar
2012-09-18  7:40 ` Dan Carpenter
2012-09-18  9:32   ` navin patidar
2012-09-18  9:36     ` Dan Carpenter
2012-09-18 11:44       ` navin patidar [this message]
2012-09-18 13:15         ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2012-09-14 13:21 navin patidar
2012-09-14 14:16 ` Dan Carpenter
2012-09-14 14:28   ` Sebastian Andrzej Siewior
2012-09-14 14:41     ` Dan Carpenter
2012-09-14  9:53 navin patidar
2012-09-14 11:42 ` Sergei Shtylyov
2012-09-14 12:04   ` Sebastian Andrzej Siewior
2012-09-14 14:29     ` navin patidar
     [not found]   ` <CAPV97yfV27x8hB2WUCVmGWEU7i21Y5K5trig2fzQBx+VB_Yk2g@mail.gmail.com>
2012-09-14 14:16     ` Sergei Shtylyov
2012-09-17 12:19 ` Greg KH

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='CAPV97yfRd_1Ak+DniNyg+vhg1bkOPqzGwRu-LSKXkpW2=_xw+Q@mail.gmail.com' \
    --to=navinp@cdac.in \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mfm@muteddisk.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;
as well as URLs for NNTP newsgroup(s).