From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754415AbbCEC6F (ORCPT ); Wed, 4 Mar 2015 21:58:05 -0500 Received: from ozlabs.org ([103.22.144.67]:52379 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754317AbbCEC6D (ORCPT ); Wed, 4 Mar 2015 21:58:03 -0500 From: Rusty Russell To: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Subject: Re: [PATCH] virtio_balloon: set DRIVER_OK before using device In-Reply-To: <1425474779-29412-1-git-send-email-mst@redhat.com> References: <1425474779-29412-1-git-send-email-mst@redhat.com> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Thu, 05 Mar 2015 13:24:47 +1030 Message-ID: <877fuwjgqw.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Michael S. Tsirkin" writes: > virtio spec requires that all drivers set DRIVER_OK > before using devices. While balloon isn't yet > included in the virtio 1 spec, previous spec versions > also required this. > > virtio balloon might violate this rule: probe calls > kthread_run before setting DRIVER_OK, which might run > immediately and cause balloon to inflate/deflate. > > To fix, call virtio_device_ready before running the kthread. > > Signed-off-by: Michael S. Tsirkin Replied, CC'd stable. Thanks, Rusty. > --- > drivers/virtio/virtio_balloon.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c > index 5a6ad6d..6a356e3 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -508,6 +508,8 @@ static int virtballoon_probe(struct virtio_device *vdev) > if (err < 0) > goto out_oom_notify; > > + virtio_device_ready(vdev); > + > vb->thread = kthread_run(balloon, vb, "vballoon"); > if (IS_ERR(vb->thread)) { > err = PTR_ERR(vb->thread); > -- > MST