WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] xen/blkfront: don't access freed stru

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] xen/blkfront: don't access freed struct xenbus_device
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 04 Feb 2010 05:20:20 -0800
Delivery-date: Thu, 04 Feb 2010 05:20:35 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1265288907 0
# Node ID 86d6c6417cf96cb018a35f300aa0b1709cf93d5c
# Parent  26a5e91e827c364950156ac13ad0f4fa859c8584
xen/blkfront: don't access freed struct xenbus_device

Unfortunately c/s 983 still wasn't quite right - there was a reference
to freed memory left from blkfront_closing().

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 drivers/xen/blkfront/blkfront.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff -r 26a5e91e827c -r 86d6c6417cf9 drivers/xen/blkfront/blkfront.c
--- a/drivers/xen/blkfront/blkfront.c   Thu Feb 04 08:54:27 2010 +0000
+++ b/drivers/xen/blkfront/blkfront.c   Thu Feb 04 13:08:27 2010 +0000
@@ -63,7 +63,7 @@
 #define GRANT_INVALID_REF      0
 
 static void connect(struct blkfront_info *);
-static void blkfront_closing(struct xenbus_device *);
+static void blkfront_closing(struct blkfront_info *);
 static int blkfront_remove(struct xenbus_device *);
 static int talk_to_backend(struct xenbus_device *, struct blkfront_info *);
 static int setup_blkring(struct xenbus_device *, struct blkfront_info *);
@@ -298,7 +298,7 @@ static void backend_changed(struct xenbu
                        xenbus_dev_error(dev, -EBUSY,
                                         "Device in use; refusing to close");
                else
-                       blkfront_closing(dev);
+                       blkfront_closing(info);
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
                up(&bd->bd_sem);
 #else
@@ -381,12 +381,11 @@ static void connect(struct blkfront_info
  * the backend.  Once is this done, we can switch to Closed in
  * acknowledgement.
  */
-static void blkfront_closing(struct xenbus_device *dev)
-{
-       struct blkfront_info *info = dev->dev.driver_data;
+static void blkfront_closing(struct blkfront_info *info)
+{
        unsigned long flags;
 
-       DPRINTK("blkfront_closing: %s removed\n", dev->nodename);
+       DPRINTK("blkfront_closing: %d removed\n", info->vdevice);
 
        if (info->rq == NULL)
                goto out;
@@ -406,7 +405,8 @@ static void blkfront_closing(struct xenb
        xlvbd_del(info);
 
  out:
-       xenbus_frontend_closed(dev);
+       if (info->xbdev)
+               xenbus_frontend_closed(info->xbdev);
 }
 
 
@@ -421,7 +421,7 @@ static int blkfront_remove(struct xenbus
        if(info->users == 0)
                kfree(info);
        else
-               info->is_ready = -1;
+               info->xbdev = NULL;
 
        return 0;
 }
@@ -484,7 +484,7 @@ int blkif_open(struct inode *inode, stru
 {
        struct blkfront_info *info = inode->i_bdev->bd_disk->private_data;
 
-       if(info->is_ready < 0)
+       if (!info->xbdev)
                return -ENODEV;
        info->users++;
        return 0;
@@ -500,13 +500,13 @@ int blkif_release(struct inode *inode, s
                   have ignored this request initially, as the device was
                   still mounted. */
                struct xenbus_device * dev = info->xbdev;
-               enum xenbus_state state = 
xenbus_read_driver_state(dev->otherend);
-
-               if(info->is_ready < 0) {
-                       blkfront_closing(dev);
+
+               if (!dev) {
+                       blkfront_closing(info);
                        kfree(info);
-               } else if (state == XenbusStateClosing && info->is_ready)
-                       blkfront_closing(dev);
+               } else if (xenbus_read_driver_state(dev->otherend)
+                          == XenbusStateClosing && info->is_ready)
+                       blkfront_closing(info);
        }
        return 0;
 }
@@ -896,7 +896,7 @@ int blkfront_is_ready(struct xenbus_devi
 {
        struct blkfront_info *info = dev->dev.driver_data;
 
-       return info->is_ready > 0;
+       return info->is_ready && info->xbdev;
 }
 
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] xen/blkfront: don't access freed struct xenbus_device, Xen patchbot-linux-2.6.18-xen <=