mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	Tejun Heo <tj@kernel.org>
Subject: Re: vhost_dev_cleanup() crash: BUG: unable to handle kernel NULL pointer dereference
Date: Tue, 31 Aug 2010 14:05:57 +0200	[thread overview]
Message-ID: <1283256357.2550.61.camel@edumazet-laptop> (raw)
In-Reply-To: <20100831111413.GB12853@elte.hu>

Le mardi 31 août 2010 à 13:14 +0200, Ingo Molnar a écrit :
> * Eric Dumazet <eric.dumazet@gmail.com> wrote:

> > 
> > Seems to be commit c23f3445e68e1
> > (vhost: replace vhost_workqueue with per-vhost kthread)
> > 
> > following patch should cure it ?
> > 
> > Thanks
> > 
> > [PATCH] vhost: stop worker only if created
> > 
> > Its illegal to call kthread_stop(NULL)
> > 
> > Reported-by: Ingo Molnar <mingo@elte.hu>
> > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> > ---
> > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> > index e05557d..0a00121 100644
> > --- a/drivers/vhost/vhost.c
> > +++ b/drivers/vhost/vhost.c
> > @@ -323,7 +323,8 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
> >  	dev->mm = NULL;
> >  
> >  	WARN_ON(!list_empty(&dev->work_list));
> > -	kthread_stop(dev->worker);
> > +	if (dev->worker)
> > +		kthread_stop(dev->worker);
> 
> Btw., i think this check should be pushed into kthread_stop() instead - 
> just like kfree(NULL) is possible as well - it simplifies cleanup 
> sequences.
> 

Sure !

Just in case, I resubmit the patch, clearing dev->worker, because I am
not sure if vhost_dev_cleanup() can be run several times on same struct
vhost_dev. Patch is needed even if you add this check in kthread_stop()

[PATCH v2] vhost: stop worker only if created

Its currently illegal to call kthread_stop(NULL)

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 drivers/vhost/vhost.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index e05557d..4b99117 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -323,7 +323,10 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
 	dev->mm = NULL;
 
 	WARN_ON(!list_empty(&dev->work_list));
-	kthread_stop(dev->worker);
+	if (dev->worker) {
+		kthread_stop(dev->worker);
+		dev->worker = NULL;
+	}
 }
 
 static int log_access_ok(void __user *log_base, u64 addr, unsigned long sz)



  reply	other threads:[~2010-08-31 12:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-31  7:57 Ingo Molnar
2010-08-31 10:50 ` Eric Dumazet
2010-08-31 11:14   ` Ingo Molnar
2010-08-31 12:05     ` Eric Dumazet [this message]
2010-08-31 12:20       ` Tejun Heo
2010-09-01 21:25       ` David Miller
2010-09-01 21:42         ` Michael S. Tsirkin
2010-09-02  1:27           ` David Miller
2010-08-31 19:19   ` Ingo Molnar

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=1283256357.2550.61.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=tj@kernel.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

all inboxes | Powered by JetHome®