From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aserp1040.oracle.com ([141.146.126.69]:23231 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751789AbaEPPNv (ORCPT ); Fri, 16 May 2014 11:13:51 -0400 Message-ID: <53762BCA.8010302@oracle.com> Date: Fri, 16 May 2014 23:16:26 +0800 From: Anand Jain MIME-Version: 1.0 To: Liu Bo , linux-btrfs@vger.kernel.org CC: Chris Murphy Subject: Re: [PATCH] Btrfs: fix NULL pointer crash of deleting a seed device References: <1399821299-15131-1-git-send-email-bo.li.liu@oracle.com> In-Reply-To: <1399821299-15131-1-git-send-email-bo.li.liu@oracle.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Sender: linux-btrfs-owner@vger.kernel.org List-ID: Tested-by: Anand Jain On 11/05/14 23:14, Liu Bo wrote: > Same as normal devices, seed devices should be initialized with > fs_info->dev_root as well, otherwise we'll get a NULL pointer crash. > > Cc: Chris Murphy > Reported-by: Chris Murphy > Signed-off-by: Liu Bo > --- > fs/btrfs/volumes.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index 49d7fab..bddf2bd 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -6058,10 +6058,14 @@ void btrfs_init_devices_late(struct btrfs_fs_info *fs_info) > struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; > struct btrfs_device *device; > > - mutex_lock(&fs_devices->device_list_mutex); > - list_for_each_entry(device, &fs_devices->devices, dev_list) > - device->dev_root = fs_info->dev_root; > - mutex_unlock(&fs_devices->device_list_mutex); > + while (fs_devices) { > + mutex_lock(&fs_devices->device_list_mutex); > + list_for_each_entry(device, &fs_devices->devices, dev_list) > + device->dev_root = fs_info->dev_root; > + mutex_unlock(&fs_devices->device_list_mutex); > + > + fs_devices = fs_devices->seed; > + } > } > > static void __btrfs_reset_dev_stats(struct btrfs_device *dev) >